Question: a) Define a class named House that store information about a house. It should comprise the following: 1. Private instance variables to store age of

a) Define a class named House that store information about a house. It should comprise the following:

1. Private instance variables to store age of the House, its type (Detached, SemiAttached, Attached) and its cost.

2. 4 constructors: No argument (sets age to 50, type to Attached and cost to 100000), one argument constructor (sets cost to a value, age - 50 and type - Attached), two argument constructors (sets age to a value, cost to a value , and type to Attached), three argument constructors (sets age to a value, cost to a value, and type to Attached, semi-detached, or detached)

3. 3 Accessor methods: - methods to return age, type and cost respectively

4. 5 Mutator methods: - 3 methods for setting the three values independently, a method to set all three values and a method to set age and cost of the house.

5. A public method called estimatePrice() that returns cost of a house based on type and age. An attached costs $100,000, appreciates 1% every year in first five years and 2% every year afterwards. A Semidetached costs $150,000, appreciates 2% every year in first five years and 3% every year afterwards. A detached costs $200,000, appreciates 2% every year in first five years and 2% every year afterwards.

6. A toString() method that returns type of the house and its age and its cost.

7. An equals() method to test for equality of two objects of class House based on type and age.

8. isLessThan() and isGreaterThan() method to compare between the prices of two objects of class House.

b) Write a test code 1. Which declares 4 house objects using 4 different constructors and output description of the 4 houses.

2. Test your accessor methods.

3. Calculate the estimated price of houses given type and age (include 1 attached and 1 detached).

a) Define a class named House that store information about a house.

E textbook-Patterns of Enterp Leicester City vs West HamA1 Basic C248 A3 2018F.pdf X+ V file:///C/u 0stuff/comp248 a3/C248 2018F.pdf Here is an example of the output to illustrate the expected behavior of your program House H1: This House is type attached. Its age is 1950 and costs $100000.0 House H2: This House is type attached. Its age is 1950 and costs $100000.0 House H3: This House is type attached. Its age is 4 and costs $120000.0 House H4: This House is type detached. Its age is 2 and costs $220000.8 Accessor Method: The housetype for house H4 is detached, its age is 2, and it costs $220000.0 The estimated price of house H3 is $104800.0 The estimated price of car H4 is $208800.0 Mutator Method: The new age for house H3 is 5 Mutator Method: The new housetype for house H3 is semi-detached Mutator Method: The new cost for house H3 is 240000.0 Mutator Method: The new house H3 age is 6 and its new cost is 245000 .0 Mutator Method: The new housetype for house H3 is semi-detached, its new age is 14and its cost is 260000.0 tostring: This House is type semi-detached. Its age is 14 and costs $260000.0 Houses H1 and H2 are equal is true Houses H1 and H4 are equal is false House H4 S less than H3 is true House H1 is greater than H3 is false O Type here to search ENG 5:00 PM US 2018-10-27

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!