This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.

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.

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.

Come up with a few candidate classes on your own and I can comment on your choices.

Rajat kumar jain
Greenhorn

Joined: Dec 22, 2011
Posts: 25

posted

0

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.

I think you're over-thinking this. The solution can be much simpler than that and more straightforward.

Start with Classes; forget about interfaces for now. This is a fairly simple problem and adding interfaces at the start tends to add too much complexity.

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.

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.