Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# Which Design Pattern could i follow for this problem.

Rajat kumar jain
Greenhorn
Posts: 25
Guyz will you please suggest me how can I proceed for this problem.

A well renowned hotel has three branches in Miami. Namely x,y and z .Each has two types of customers. Regular and Rewardee. Also each branch has its own ratings x is given a 3 star rating while y has 5 star rating and z has 4 star rating.Each hotel has specific rates for weekend and weekdays. x charges \$100 for regular customers on weekdays and \$120 on weekends While it is \$90 for rewardee on weekdays and \$95 on weekends. While z charges \$195 for regular customers on weekdays and \$150 on weekends. While its \$120 for rewardee on weekdays and \$90 on weekends. Now when the customer requests for a particular detail you need to find which hotel would yield the customer profit. In case of tie between hotels compare the ratings and provide the result.

Input format:Regular: 16Mar2010(sun), 19Mar2010(wed), 21Mar2010(Fri)

Answer: (This is the format of the question but not sure about the values).

Junilu Lacar
Bartender
Posts: 7777
62
Looking for a design pattern that fits this problem is not going to be very useful: there is none. The only advice I can give on how to proceed with this is the same thing you do for any problem: Break it down into smaller pieces, lay out what you know, what it is you are trying to figure out, and the steps you need to take to turn what you know into what you want to figure out.

Rajat kumar jain
Greenhorn
Posts: 25
Thank you for advice. Can you suggest me which classes should I make so as to minimize coupling and maximize cohesion. Please help me

Junilu Lacar
Bartender
Posts: 7777
62
Come up with a few candidate classes on your own and I can comment on your choices.

Rajat kumar jain
Greenhorn
Posts: 25
An interface Conditions
RegularAndWeekdays, RegularAndWeekends, RewardedAndWeekdays, RewardedAndWeekends are the classes implement them
An interface Hotel
HotelX HotelY HotelZ will implement that interface
Now all the conditions concrete classes will have a reference to hotel and it will instantiates each type of hotel
these classes have a function Calculate and they will calculate the charges for each hotel and then put them into the int variables
then i will find the smallest one of these ints and return that variable.

Junilu Lacar
Bartender
Posts: 7777
62
I think you're over-thinking this. The solution can be much simpler than that and more straightforward.

And I'm not sure you really need a "Conditions" concept yet.

HotelX, HotelY, HotelZ implementing a Hotel Interface is not right. X, Y, and Z are all Hotels. At most, I would think they would be instances of the same class.

Junilu Lacar
Bartender
Posts: 7777
62
Look at the names RegularAndWeekdays, RegularAndWeekends, etc.

The fact that you have "And" in the names is a red flag -- you need to break these things down into smaller concepts. Don't mix two different concerns.