Thread: public method
View Single Post
Old Nov 21st, 2007, 8:23 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: public method

Why don't you consider this as a problem-solving exercise, and not as a programming exercise. That way you can design your solution, then implement it.

It's pretty clear. You have a list of rooms. These rooms are given from the beginning (lowest numbered room first). They may be vacated in any order.

Each time you need a vacant room, you begin with the first room and go up the list until you find a vacant room.

Obviously, there are conditionals involved. IF a room is not vacant, you can't give it out. If the hotel is full, you can't give out a room. Isn't that easy, if you just think about it and don't get dranoed because it's a "programming" assignment?

Hint: when it comes to the code, think array or list.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote