August
1999 QUESTION 4 Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
(a) | Define the term inheritance with
respect to object oriented programming.
|
[2] |
(b) | The government
requires a program to keep records of all the buildings in the city. Each building has a
number of floors (an integer), and address (a string) and a rental cost (an integer). Implement the class building that contains :
|
[5] |
(c) | A House is a
building that has a number of residents, and rent of 200 dollars per resident. Use
inheritance to implement a class House, with a constructor that takes the parameters the number of
residents, the address, and the length of the address, and initializes all of its members
appropriately. All members which are not passed as parameters to the constructor should be
initialized to 0.
|
[5] |
(d) | An estate is a
collection of buildings. Consider the following definition of a class Estate : class Estate { Give an implementation of a function total_rental_value that takes a reference to an estate, and returns the total rental value of all the buildings on the estate.
|
[6] |
(e) | In the Estate class, there is a
problem that relates to calculating the rental cost of houses. Identify, and explain the
nature of this problem.
|
[2] |