954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help for hotel management system

i have to create a n hotel management program using GUI, i hava done the gui part so far but i need help in creating the actionPerformed class,how am i supposed to do the reservation,and select rooms for 2 persons or one and rooms that overlook the sea or the road,this kind of stuff,please help me ,i heve to do it in 2 days.thanks

pucivogel
Newbie Poster
15 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 
how am i supposed to do the reservation,and select rooms for 2 persons or one and rooms that overlook the sea or the road

Could you please post your whole assignment, including the GUI-code you have written so far?

tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
 

Forget the GUI for the moment. Go back to where you should have started, which is the hotel model. You need to design some simple classes for entities such as Room ( attributes: no of beds, sea view etc), Hotel (a collection of Rooms with methods for finding vacant Rooms with specific attributes), and Reservation (person, Room, dates etc).
Define these classes with simple constructors, and public methods for the things you want to do (eg find a twin room with sea view, create a new Reservation for that Room).
Write some simple hard-coded tests in a main(..) method to make sure they work.
Now go back to the GUI - your ActionPerformed will just be just like the tests you coded but with data from the GUI fields.

JamesCherrill
Posting Genius
Moderator
6,337 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,070
 

i have done only one option,if the rooms are for 2 or for 1 person.i type in the name ,the option and the result in the text area appears even before i press save and its always room number 10 ,i would also like to add it another option for ex viewing the sea or the road and how can i make it to appear a second panel demostrating the name room and that the reservation was really successful.i am sorry for so much questions but i am a beginner.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class HotelManagement extends JFrame implements ActionListener
{ JLabel tekst1=new JLabel("Name ");
  JTextArea intekst1= new JTextArea(1,7);
  JLabel tekst2=new JLabel("Surname ");
  JTextArea intekst2= new JTextArea(1,7);
  JPanel tekst1Panel= new JPanel();
  JPanel tekst2Panel= new JPanel();
  JTextArea ana= new JTextArea(2,25);
  JRadioButton couple=new JRadioButton("Couple room");
  JRadioButton one=new JRadioButton("One person");
   ButtonGroup choiceGroup= new ButtonGroup();
  JButton save= new JButton("Save");
  
  public HotelManagement()
  {super ("Hotel Management");
   setSize(350,250);
   setVisible(true);
   
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   
   choiceGroup.add(dhomaCift);
   choiceGroup.add(dhomaTek);
   
   JPanel choicePanel= new JPanel();
   choicePanel.setLayout(new BoxLayout(choicePanel,BoxLayout.Y_AXIS));
   choicePanel.add(dhomaCift);
   choicePanel.add(dhomaTek);
   
   Container content= getContentPane();
   FlowLayout lay=new FlowLayout(FlowLayout.LEFT);
   content.setLayout(lay);
   setBackground(Color.blue);
   
   
   couple.addActionListener(this);
   one.addActionListener(this);
   save.addActionListener(this);
   
   
   tekst1Panel.add(tekst1);
   tekst1Panel.add(intekst1);
   tekst2Panel.add(tekst2);
   tekst2Panel.add(intekst2);
   
   content.setLayout(lay);
   content.add(tekst1Panel);
   content.add(tekst2Panel);
   content.add(zgjedhjePanel);
   content.add(ana);
   content.add(rezervo);
   
   setContentPane(content);
    }
  public void savecoupleroom()
  {String[] coupleroom={"1","2","3","4","5","6","7","8","9","10"};
        for(int i=0 ;i<=coupleroom.length;i++)
        {if (i>coupleroom.length)
             {String str="No more couple rooms";
              ana.setText(str);}
        else{ coupleroom[i]=coupleroom[i+1];
             String str1="Couple room"+coupleroom[i]+"saved";
              ana.setText(str1);}
        }
  }
  public void saveoneroom()
  {String[] oneroom={"1","2","3","4","5","6","7","8","9","10"};
        for(int i=0 ;i<=oneroom.length;i++)
        {if (i>oneroom.length)
             {String str="No more rooms for one person";
             ana.setText(str);}
        else{ oneroom[i]=oneroom[i+1];
        String str1="One person room"+oneroom[i]+"saved";

        ana.setText(str1);}
        }
  }
  public void actionPerformed(ActionEvent event)
  {  if(event.getSource()==couple)
         {savecoupleroom();}
	  if (event.getSource()==one)
	  {saveoneroom();}
	  
	  
  }
  
  
  
  
  
  public static void main(String[] args)
  {HotelManagement manage= new HotelManagement();}
  
  
  

}
pucivogel
Newbie Poster
15 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You