Name: _____________________                                                                                           September 23, 2003

Queens College, CS211                                                                                                           Instructor:  Ke Tang

 

Quiz #1, Version A

 

Directions:  Answer the question by writing code to solve the following problem.  You should answer this quiz directly on the paper, using a pen.  If you need extra space, you may use a sheet of your own paper.  However, please make sure that any extra paper that you submit has your name written on every page, and is stapled to the quiz.

 

Note:  This quiz is open book/open notes

 

For this quiz, you will be asked to design (declare) and implement (define) a class, Room, that models certain properties of the object room.  You will also be asked to write a function that uses this room in the way described below:

 

1.  Write a complete .h file for the class Room.  It should be able to store the number of seats in the room (an int), the name of the building (string) and the room number (int).  It should contain a constructor that accepts 3 parameters and sets the variables of the class to these parameters.  It should also have accessor functions for each of the variables.  Furthermore, it should have a mutator function for the number of seats.  Also, provide any other functions that may be required by this class.

 

2.  Write portions of the .cpp file for this class, implementing the following functions:

A:  The 3 parameter constructor

B:  The accessor function for number of seats

C:  The mutator function for the number of seats, making sure that the number of seats cannot be less than 0 nor more than 100.

 

It is not required for you to provide code for the other functions in the .cpp file.

 

3.  Write a function that accepts as a parameter an instance of the class Room.  It returns as an integer, the number of square feet that is required to accommodate the number of chairs in the room.  Assume that each chair requires 10 square feet.