Assignment 1

 

Description

You must implement a C++ class to model a building
with  floors 0, 1, 2  and rooms 0, 1, 2, 3, 4
on each floor.  If a room is occupied your building keeps
track of the occupant's  name and ID number. Both the name and
ID number are character strings (you may assume they are not
longer than 30 characters each).
 

Define a class     building        that has the following interface:
 

//Default Constructor
//Creates new building with all rooms empty 
building( );

//Constructor
//Creates a new building with  one person with name s[ ] and ID number N[ ], 
//into room 0 on floor 0.
building(const char s[ ], const char N[ ], );

//Puts person with name s[ ] and ID number N [ ] into
//room on floor f and room number n. If f and n are out of range it prints an error message.
void Put(char s[ ], char N[ ], int f, int n);

//Defines room on floor f and number n to be empty
void Empty(int f, int n);

//Prints name/ID No. of occupant of room on floor f and number n
//If room is empty prints message "Room n on floor f is empty"
//where n,f are replaced by the appropriate values. If f and n are out of range it prints an error message.
void Display(int f, int n);

//Prints, in alphabetical order, one person per line, the
//name/ID No of all occupants of floor f in the form <name><tab><id>.
//If floor is empty it prints the message "Floor f is empty"
//where f is replaced by the appropriate values. If  f is out of range it prints an error message
void Display(int f);

//Prints, in alphabetical order,
// name/ID Nos  of all occupants of building
//If building is empty prints message
//"Building is empty"
void Display( );

//returns the number of empty rooms on floor f. If f is out of range it prints an error message.
int Vacancies(int f);

//returns the number of empty rooms in the building
int Vacancies( );

//Overloads the << operator for  buildings, such that it prints  the names of the persons that occupy a building.
friend ostream& operator<<(ostream& outs, const building& name);

//Overloads the ==operator so that it returns true if two buildings have the same
//number of persons otherwise false
friend bool operator==(const building& b1, const building& b2);

//Prints YOUR name, ID Number, Lecture and Lab section in the following format
//<name><tab><ID><tab><Lecture><tab><Lab section> 
//This will be used for marking purposes
void Identify_Writer( );
 

The file     building.h            should contain the class definition,
The file     building.cpp       should contain the implementation.
 
 

Input Format

Your program does not have to read any input.

Output format

Described in the interface
 

Testing your program

We will test your files by compiling them together with another program that will call all of your functions and
check if they perform correctly. You must test your files yourself and satisfy yourself that you've covered all
possibilities.

We provide a small driver program CheckBuilding.cpp  that can be compiled together with
building.h and building.cpp to test a few cases.

Note that this program DOES NOT cover all possible test cases and is not the program that we will actually
use to compile your program

 

Assessment task

Our system will collected the files under ~/comp151/assign1 on Monday 19 March at midnight