You are to design a solution to the following problem. For full points on this q
ID: 3535812 • Letter: Y
Question
You are to design a solution to the following problem. For full
points on this question all of the following must be included:
Inheritance
Efficient code
Acceptable design
Your data definition classes should include:
Homes
Instance variables:
1. address
2. cost per month (between $1000 and $4000)
3. accessor/mutator (get/set) for cost
4. Overridden toString() method
Apartments (subclass of Homes) -
Instance variables:
1. Number of Parking Spaces (between 0 and 4)
* Each space increases the cost per month by $10
2. Include an overridden toString() method and a getSpaces()
method
SingleFamily (subclass
of Homes) -
Instance variables:
1. Renters Insurance as a boolean variable.
If renters insurance is accepted,
the cost per month increases by $25
2. Include a toString() method
Your Application should include the following:
Driver->main():
1. Create an array (not ArrayList) of Homes (no more than 30,
user can enter as many as he/she would like , avoid array index out of bounds exception)
2. Give the user a choice between Apartment and Single
Family
3. Based on their choice, call the appropriate method
(makeApartment() or makeSingleFamily())
4. For each home, input the address and cost per month
5. Output a summary for each entry as address
and cost
Methods in Driver:
makeApartment():
Create an Apartment object
Fill with number of desired parking spaces
Methods in Driver:
makeSingleFamily()
Create a SingleFamily object
Fill with the choice of renters insurance
(yes/no)
Explanation / Answer
.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.