943,096 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 841
  • Java RSS
Jan 24th, 2010
0

need help for hotel management system

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pucivogel is offline Offline
15 posts
since Jan 2010
Jan 24th, 2010
0
Re: need help for hotel management system
Quote ...
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?
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Jan 24th, 2010
0
Re: need help for hotel management system
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.
Featured Poster
Reputation Points: 1895
Solved Threads: 944
Posting Expert
JamesCherrill is offline Offline
5,741 posts
since Apr 2008
Jan 24th, 2010
0
Re: need help for hotel management system
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.
Java Syntax (Toggle Plain Text)
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. public class HotelManagement extends JFrame implements ActionListener
  5. { JLabel tekst1=new JLabel("Name ");
  6. JTextArea intekst1= new JTextArea(1,7);
  7. JLabel tekst2=new JLabel("Surname ");
  8. JTextArea intekst2= new JTextArea(1,7);
  9. JPanel tekst1Panel= new JPanel();
  10. JPanel tekst2Panel= new JPanel();
  11. JTextArea ana= new JTextArea(2,25);
  12. JRadioButton couple=new JRadioButton("Couple room");
  13. JRadioButton one=new JRadioButton("One person");
  14. ButtonGroup choiceGroup= new ButtonGroup();
  15. JButton save= new JButton("Save");
  16.  
  17. public HotelManagement()
  18. {super ("Hotel Management");
  19. setSize(350,250);
  20. setVisible(true);
  21.  
  22. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  23.  
  24. choiceGroup.add(dhomaCift);
  25. choiceGroup.add(dhomaTek);
  26.  
  27. JPanel choicePanel= new JPanel();
  28. choicePanel.setLayout(new BoxLayout(choicePanel,BoxLayout.Y_AXIS));
  29. choicePanel.add(dhomaCift);
  30. choicePanel.add(dhomaTek);
  31.  
  32. Container content= getContentPane();
  33. FlowLayout lay=new FlowLayout(FlowLayout.LEFT);
  34. content.setLayout(lay);
  35. setBackground(Color.blue);
  36.  
  37.  
  38. couple.addActionListener(this);
  39. one.addActionListener(this);
  40. save.addActionListener(this);
  41.  
  42.  
  43. tekst1Panel.add(tekst1);
  44. tekst1Panel.add(intekst1);
  45. tekst2Panel.add(tekst2);
  46. tekst2Panel.add(intekst2);
  47.  
  48. content.setLayout(lay);
  49. content.add(tekst1Panel);
  50. content.add(tekst2Panel);
  51. content.add(zgjedhjePanel);
  52. content.add(ana);
  53. content.add(rezervo);
  54.  
  55. setContentPane(content);
  56. }
  57. public void savecoupleroom()
  58. {String[] coupleroom={"1","2","3","4","5","6","7","8","9","10"};
  59. for(int i=0 ;i<=coupleroom.length;i++)
  60. {if (i>coupleroom.length)
  61. {String str="No more couple rooms";
  62. ana.setText(str);}
  63. else{ coupleroom[i]=coupleroom[i+1];
  64. String str1="Couple room"+coupleroom[i]+"saved";
  65. ana.setText(str1);}
  66. }
  67. }
  68. public void saveoneroom()
  69. {String[] oneroom={"1","2","3","4","5","6","7","8","9","10"};
  70. for(int i=0 ;i<=oneroom.length;i++)
  71. {if (i>oneroom.length)
  72. {String str="No more rooms for one person";
  73. ana.setText(str);}
  74. else{ oneroom[i]=oneroom[i+1];
  75. String str1="One person room"+oneroom[i]+"saved";
  76.  
  77. ana.setText(str1);}
  78. }
  79. }
  80. public void actionPerformed(ActionEvent event)
  81. { if(event.getSource()==couple)
  82. {savecoupleroom();}
  83. if (event.getSource()==one)
  84. {saveoneroom();}
  85.  
  86.  
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93. public static void main(String[] args)
  94. {HotelManagement manage= new HotelManagement();}
  95.  
  96.  
  97.  
  98.  
  99. }
Last edited by Nick Evan; Jan 24th, 2010 at 3:15 pm. Reason: Fixed code-tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pucivogel is offline Offline
15 posts
since Jan 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: adding panel inside panel using inspector in netbeans
Next Thread in Java Forum Timeline: Help with JPanels





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC