Residence Class
The constructor takes an int for number of rooms, an int for number of external walls, and a boolean for whether or not there is a washer.
Residence also has 4 methods:
-
hasWasher()
, which returns a boolean. It returns whether or not there is a washer in the residence. This method should be protected, which means only classes derived from Residence can access it.
As a reminder, public members and methods are accessible
from any class, while private members and methods are only
accessible from within the class in which they are declared. The
protected keyword can be thought of as midway between
public
and private
. Classes that do not inherit
from (using extends
) a class with a protected
item
may not access it.
-
propertyValue()
, which returns a double. It calculates the property value based on number of rooms * 10000. -
numWindows()
, which returns an int. It calculates the number of windows based on the number of external walls * 2. -
toString()
, which returns a string containing the number of rooms, the number of walls, whether or not there is a washer, the number of windows, and the property value.
The output of toString()
should be similar to the following.
Number of Rooms: 4 Number of Walls: 4 Washer: true Number of Windows: 8 Property Value: 40000.0