Question: need help writing the code for this example in java please! thanks:) Question 2 (Simple Class Exercise) a) Define a class named House that store


need help writing the code for this example in java please! thanks:)
Question 2 (Simple Class Exercise) 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, Semi Attached, Attached) and its cost. 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 Accessor methods: - methods to return age, type and cost respectively 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. 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 Semi detached 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. A toString() method that returns type of the house and its age and its cost. An equals() method to test for equality of two objects of class House based on type and age. 2. 4. 5. 6. 7. 8. isLessThan() and isGreaterThan() method to compare between the prices of two objects of class House. Question 2 (Simple Class Exercise) 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, Semi Attached, Attached) and its cost. 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 Accessor methods: - methods to return age, type and cost respectively 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. 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 Semi detached 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. A toString() method that returns type of the house and its age and its cost. An equals() method to test for equality of two objects of class House based on type and age. 2. 4. 5. 6. 7. 8. isLessThan() and isGreaterThan() method to compare between the prices of two objects of class House
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
