Question: In this assignment you will develop a class (House,java) that will hold information about a house. You will then develop a class (HouseTest.java) in which
In this assignment you will develop a class (House,java) that will hold information about a house. You will then develop a class (HouseTest.java) in which you will create three instances of the class house, allow the user to enter the information for each house, print to the screen the information for all of the houses and print to the screen the information for those houses that fulfill the users criteria.
Part A:
You are to develop the class House (name the class House.java) that has:
1. The following instance variables:
private String address;//Street, Town, State
private int squareFeet;
private int cost;
private int lotSize; //in square feet
private int bedrooms;
private int bathrooms;
2. Getter and setter methods for all of the instance variables above. The setter methods must trap the user (if invalid information is passed) asking them to input a new value. Valid values are as follows:
squareFeet //must be > 0
cost //must be >= 0
lotSize //must be > 0
bedrooms //must be > 0
bathrooms //must be > 0
3. A method that will calculate and return the cost per square food of the house.
4. A method (name the method toString) that will return a String as follows:
Address: %1s Square Feet: %1d Cost: $%1d Lot Size: 1d Bedrooms: %1d Bathrooms: %1d, address, squareFeet, cost, lotSize, bedrooms, bathrooms
Part B:
You are to develop a class HouseTest (name the file HouseTest.java) that:
Creates three instances of the class House
Asks the user for all the information of each house (address, squareFeet etc) and passes that information to the appropriate setters
Asks the user to enter the specifics of the house they want (bedrooms, bathrooms, maximum price, minimum lot size) and saves those values.
Prints to the screen the values stored in the instance variables (you will do that by calling the method toString from Part A #4 above) of all the instances of the class House.
Prints to the screen the values stored in the instance variables (you will do that by calling the method toString from Part A #4 above) and the price per square foot (you will get that by calling the method developed in Part A #3 above) of all the instances of the class House from Part B #1 and #2 above that meet the desires of the user (the house has the number of bedrooms the user wants, the house has the number of bathrooms the user wants, the house has a price that is less than or equal to the maximum the user wants to pay and has a lot size that is greater than or equal to the minimum lot size the use will accept).
Submit both classes (House.java and HouseTest.java)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
