-
November 17th, 2008, 09:38 AM
#1
No clue how to even start
Create a class for reservation of passenger cabins in a ferry. Assume that there are three types of cabins,
Type A : a cabin with a single bed, it accommodates a single passenger per cabin.
Type B : a cabin with two beds, it accommodates upto two passengers per cabin.
Type C : a cabin with four beds, it accommodates upto four passengers in a
cabin.
Assume that the passenger beds in each cabin are numbered, thus the beds in a cabin for two passengers are numbered as 0 and 1 and in a cabin for four passengers are numbered as 0, 1, 2, and 3. If a bed has been assigned to a passenger, then its status is true otherwise false.
The number of each type of cabins is given by,
No_A= number of type A cabins.
No_B= number of type B cabins.
No_C= number of type C cabins.
A reservation may request accommodation for a group of 1, 2 or 4 passengers. The passengers in a group will only stay in a single cabin and they cannot be split into multiple cabins. On the other hand, if the passengers in a group cannot find a single cabin accommodation, they may share a cabin with other groups of passengers. Thus the first choice of a single passenger is to stay in a cabin for one passenger, his second choice will be to share a cabin for two passengers, and his last choice will be to share a cabin for four passengers.
Class should have the following public functions,
Constructor function // It should generate a ferry object with the status of all the
passenger beds in the cabins false.
int get_available(char) // This function returns the number of available passenger
// beds a type of cabins. The parameter of the function
// specifies the cabin type as A, B or C.
bool assign_passengerbeds ( int b)
// The above function assigns b passenger beds according to the rules specified above, where b assumes the values of 1, 2, 4. If the assignment is successful it returns true and otherwise false.
Write the implementation of this class as well as test it with a driver program.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|