CS 37                                                                                     

                                    LAB 8 – composite classes, dynamic storage

 

/* class room */

class room{

private:

            double length;

            double width;

            int num_windows;

            void setroom(double l, double w, int n);

            void print();

            double area();

};

 

void room::setroom(double l, double w, int n){

            length=l;

            width=w;

            num_windows=n;

}

 

void room::print(){

           

 

/*class apartment */

class apartment{

private:

            room *r;

            int num_rooms;

            double rent;

public:

            apartment(int n,double rnt);

            void print();

            double area();

            void setapartment();

};

                       

apartment::apartment(int n,double rnt){

            num_rooms=n;

            rent=rnt;

            r = new room[num_rooms];

}

 

void apartment::print(){

 

// Function print will display all information about the apartment and the rooms within the apartment:  the number of rooms, the dimensions of each room, the number of windows in the room, and the rent.

 

}

 

double apartment::area(){

 

//Function area will display the number of square feet in the apartment.  This number is calculated by adding the number of square feet in each room.

 

}

 

void apartment::setapartment(){

 

//function setapartment prompts the user for the following information: the length and width of each room, and the number of windows in each room.

 

}

 

 

Write the methods for class room and class apartment.  Write a main procedure that declares an object a, of type apartment.  Test out all the methods in the main procedure.

 

THIS LAB IS DUE IN TWO WEEKS.