building a class help


Show an understanding of how concepts of inheritance can be used to generate effective and resuable solutions.
Ensure students understand how data abstraction (e.g. classes/objects) is used in developing solutions
Ensure students understand how to declare classes and instantiate objects

Write a class named Building. Your class should store a name for your building, the number of occupants, and whether or not the building is open.
Your class should have two Constructors.

A default constructor that sets the name to an empty string, the building to open (true), and the number of people to 0.
An overloaded constructor that takes in a name as a parameter and sets the building's name to it. It should also set your building to open and the number of people to 0.
In addition, your class should be able to add a specific number of people to a building and display how many people are in that building (this should include the building's name and the number of people inside), and it should also be able to evacuate a building. Evacuating a building clears out all the occupants (sets the number of people inside to 0) and closes the building and also display that the building has been evacuated (include the building's name and the number of people inside).

Write a class Library that is a derived/child/sub- class of Building. It has one new attribute that keeps track of the number of books in the library and a Constructor that sets this number. Your Library class should pass a name to your Building class's Constructor.

Inside of main:

Create two Building objects
Create one Library object.
Populate all three buildings
Evacuate all three buildings.

Deal with the building class first and make sure it works before moving to your Library class.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!