• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with a booking system

 
Robert Staniforth
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I'm trying to get this hotel booking system sorted out so I can put a customer in a certain room, but i'm not really sure how to do it exactly. Would really appreciate some help, all the stuff I've tried so far has been a complete failure :/
(I wasn't really sure what to title this, sorry)







 
moh oo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
By looking at your code, I think you can create a enum data type for room type (to improve, just what i think ). Also, in the bedroom constructor, you have a if condition, which i think is not so clear. accepting 'n' and 'r' values as parameters. then you assign them back (with a hard coded values). you would put something more realistic. it is something i can think of by brief look. I hope it helps
 
Robert Staniforth
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the if statement is: there are only rooms 201-> 212 and rooms 201 to 203 are single rooms, therefore have a different rate to the double which are 204-> 212
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch moh moh oo .
Please check your Private messages.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a continuation of your previous thread, in the future, don't start a new one.

The code where you set a rate is... highly local:So... what impact does this code have outside the constructor itself? (Hint: none.) You set a parameter you pass in to the method: isn't your goal to set the rate for the room? Where/in what variable is the room rate visible to anything that might use it? Where is the parameter "r" visible?
 
Prince Manchanda
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Robert,

To start with I see following two problems with your code:

  • First, In the constructor of your class Bedroom, you are trying to set the values for the input arguments.




  • It should be something like this



    Trying changing that and see if it works
  • Second, is the more fundamental problem of OOPS. You are trying to put the business logic in the classes that represent that your entities. To start with you can have the following approach:






  • Then add a following class that will hold your logic for bookings
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic