Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 24th, 2006, 9:20 PM   #1
Watts
Newbie
 
Watts's Avatar
 
Join Date: Feb 2006
Location: Rochester, NY
Posts: 18
Rep Power: 0 Watts is on a distinguished road
Java CS Project

I have to do this project for CS2. I'm not too excited, but I'll post the code when I finish it if anyone's interested. I'll definitely have it done by Sunday.
Watts is offline   Reply With Quote
Old Feb 24th, 2006, 9:33 PM   #2
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 843
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
That's a lot of work for one weekend.
titaniumdecoy is offline   Reply With Quote
Old Feb 24th, 2006, 9:37 PM   #3
Watts
Newbie
 
Watts's Avatar
 
Join Date: Feb 2006
Location: Rochester, NY
Posts: 18
Rep Power: 0 Watts is on a distinguished road
Not at all. It will take 5-8 hours max. Gui's aren't that hard to make in java.
Watts is offline   Reply With Quote
Old Feb 24th, 2006, 9:50 PM   #4
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Hey! I am definitly! Looks rather exciting to create something like that!
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Feb 25th, 2006, 4:44 PM   #5
Watts
Newbie
 
Watts's Avatar
 
Join Date: Feb 2006
Location: Rochester, NY
Posts: 18
Rep Power: 0 Watts is on a distinguished road
Alright, I've spent almost 2 hours on it and here's the main GUI

[HTML]
/**
* Hotel.java
*
* A program designed to reserve rooms during 2006 for a basic hotel
*/

/**
* @author John Watts
*
*/

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.Border;


public class Hotel extends JPanel implements WindowListener, ActionListener{
static JFrame frame;
JPanel welcome, rates, availability;
JLabel ratesLabel,welcomeLabel,textLabel;
Border titledBorder;

public Hotel(){
super(new BorderLayout());

frame.getContentPane().add(this);
frame.addWindowListener(this);

//~North Panel
welcome = new JPanel(new FlowLayout(1));
welcome.setBackground(Color.WHITE);
this.add(welcome, BorderLayout.NORTH);

welcomeLabel = new JLabel("Welcome to the Hotel Reservation System");
welcome.add(welcomeLabel);
//~End North Panel

//~West Panel
rates = new JPanel(new GridLayout(10,1));
rates.setBackground(Color.YELLOW);
this.add(rates, BorderLayout.WEST);

ratesLabel = new JLabel("Rates for 2006:");
rates.add(ratesLabel);
ratesLabel = new JLabel(" ");
rates.add(ratesLabel);
ratesLabel = new JLabel("Single Room: $100");
rates.add(ratesLabel);
ratesLabel = new JLabel("Double Room: $125");
rates.add(ratesLabel);
ratesLabel = new JLabel("King Room: $150");
rates.add(ratesLabel);
ratesLabel = new JLabel(" ");
rates.add(ratesLabel);
ratesLabel = new JLabel("Rates given are per night,");
rates.add(ratesLabel);
ratesLabel = new JLabel("smoking or non-smoking");
rates.add(ratesLabel);
ratesLabel = new JLabel(" ");
rates.add(ratesLabel);
ratesLabel = new JLabel(" ");
rates.add(ratesLabel);
//~End West Panel

//Center Panel
Border availabilityBorder = BorderFactory.createTitledBorder(
"Check Availability");
JPanel availability = new JPanel(new GridLayout(5,1));
availability.setBackground(Color.CYAN);
this.add(availability, BorderLayout.CENTER);

textLabel = new JLabel("Select a room:");
availability.setBorder(availabilityBorder);
availability.add(textLabel);

//Room button row
JPanel buttonGroup = new JPanel(new FlowLayout(1));
buttonGroup.setBackground(Color.CYAN);
ButtonGroup roomSize = new ButtonGroup();
JRadioButton singleRoom = new JRadioButton("Single");
singleRoom.setBackground(Color.CYAN);
roomSize.add(singleRoom);
JRadioButton doubleRoom = new JRadioButton("Double");
doubleRoom.setBackground(Color.CYAN);
roomSize.add(doubleRoom);
JRadioButton kingRoom = new JRadioButton("King");
kingRoom.setBackground(Color.CYAN);
roomSize.add(kingRoom);
buttonGroup.add(singleRoom);
buttonGroup.add(doubleRoom);
buttonGroup.add(kingRoom);
availability.add(buttonGroup);
//End room button row

//Smoking row
JPanel smokingPanel = new JPanel(new FlowLayout(1));
smokingPanel.setBackground(Color.CYAN);
ButtonGroup smokingGroup = new ButtonGroup();
JRadioButton smoking = new JRadioButton("Smoking");
smoking.setBackground(Color.CYAN);
smokingGroup.add(smoking);
JRadioButton nonsmoking = new JRadioButton("Non-smoking");
nonsmoking.setBackground(Color.CYAN);
smokingGroup.add(nonsmoking);
smokingPanel.add(smoking);
smokingPanel.add(nonsmoking);
availability.add(smokingPanel);
//End Smoking row

//Month Menu
JPanel monthPanel = new JPanel(new FlowLayout(3));
monthPanel.setBackground(Color.CYAN);
textLabel = new JLabel("Select Month:");
monthPanel.add(textLabel);
String[] months = { "Months", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"};

JComboBox monthList = new JComboBox(months);
monthList.setSelectedIndex(0);
monthPanel.add(monthList);
//monthList.addActionListener(this);
availability.add(monthPanel);
//End Month Panel

JPanel choose = new JPanel(new FlowLayout(1));
choose.setBackground(Color.CYAN);
JButton chooseDates = new JButton("Choose Dates");
choose.add(chooseDates);
availability.add(choose);
//End Center Panel

//East Panel Void

//South Panel
JPanel southPanel = new JPanel(new FlowLayout(1));
southPanel.setBackground(Color.BLUE);
JButton reserve = new JButton("Reserve Room");
southPanel.add(reserve);
JButton reset = new JButton("Reset");
southPanel.add(reset);
this.add(southPanel, BorderLayout.SOUTH);
//Reserve Room Reset
//End South Panel


addComponents();

}

public void addComponents(){

}
public void windowOpened(WindowEvent e){}
public void windowClosing(WindowEvent e){
frame.dispose();
}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void actionPerformed(ActionEvent e){}
public static void createAndShowGUI(){
//Create and set up the window.
frame = new JFrame("Hotel");
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

//Create content pane
JComponent newContentPane = new Hotel();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);

//Display
frame.pack();
frame.setVisible(true);
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
javax.swing.SwingUtilities.invokeLater(new Runnable(){
public void run(){
createAndShowGUI();
}
});

}

}
[/HTML]

I didn't add any actions to the buttons yet, but this is the basic build. I think I came pretty close to the example's design.
Watts is offline   Reply With Quote
Old Feb 27th, 2006, 7:16 AM   #6
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
you could save a lot of lines by using
[PHP]
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
[/PHP]
thats only 3 lines vs your 18!
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Mar 2nd, 2006, 12:33 AM   #7
Watts
Newbie
 
Watts's Avatar
 
Join Date: Feb 2006
Location: Rochester, NY
Posts: 18
Rep Power: 0 Watts is on a distinguished road
I use eclipse, so ctr shift o is easy
Watts is offline   Reply With Quote
Old Mar 2nd, 2006, 2:54 AM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by Watts
I use eclipse, so ctr shift o is easy
Also, generally speaking, "import javax.swing.BorderFactory" is preferable to "import javax.swing.*", in that it tells anyone reading your code exactly which classes are from which library.
Arevos is offline   Reply With Quote
Old Mar 2nd, 2006, 3:03 PM   #9
Watts
Newbie
 
Watts's Avatar
 
Join Date: Feb 2006
Location: Rochester, NY
Posts: 18
Rep Power: 0 Watts is on a distinguished road
I finished it, I don't like it. I rushed through it to meet the deadline and I don't think its worth posting. Sorry.
Watts is offline   Reply With Quote
Old Mar 2nd, 2006, 4:07 PM   #10
.TD
Programmer
 
.TD's Avatar
 
Join Date: Feb 2006
Location: UK
Posts: 36
Rep Power: 0 .TD is on a distinguished road
Question

umm one thing...
Quote:
You may get help from your instructor(s) and the teaching assistants. Anything else is not allowed and is subject to the penalties listed in the DCS Policy on Academic Dishonesty. This includes but is not limited to:
  • Obtaining detailed help from any other people
  • Providing detailed help to other people
  • Sharing source code with anyone, by any means or medium.
Havn't you just violated that last rule? OK we are not on your course or anything but anyone that is could just as easily see the code?

...Just a thought.
__________________
Go away before I replace you with a very small shell script.
--
Get FireFox!
.TD is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:58 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC