CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    1

    Unhappy 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.

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: No clue how to even start

    Buy a book about C++ and read it.
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    May 2002
    Posts
    1,435

    Re: No clue how to even start

    When homework is assigned it is usually based on chapters in a textbook that you were assigned to read and explanations that the instructor offered in class. Re-read the chapters that were assigned, review the notes you took in class, make an attempt to start the code, then post what you have done. At that point you will find everyone willing to help.

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
  •  





Click Here to Expand Forum to Full Width

Featured