Question
The House Class Sophie, Sally and Jack have decided to develop a housing subdivision. The first thing they'll need is a House class. The houses
The House Class
Sophie, Sally and Jack have decided to develop a housing subdivision. The first thing they'll need is a House class. The houses will be all be very similar: a living area for formal entertainment, a family area for everyday activities, and some number of bedrooms, each with a bath. The houses will also have various amounts of land surrounding them.
Write a class House. The purpose of a House object is to represent a single house with its plot of land in a subdivision. The House class has the following specification:
Instance Variables
- instance variable of type int for the number of bedrooms.
- instance variable of type double for the size in square feet of the family room
- instance variable of type double for the size in square feet of the living room
- instance variable of type String that describes the style of the house ("Colonial," "Ranch," "motte-and-bailey," etc)
- instance variable of type double for the size in acres of the plot that surrounds the house
Constructors
House has two constructors
- a no-argument constructors
a constructor that takes five parameterS (in this order):
- the style of the house
- the area of the family room
- the area of the living room
- the number of bedrooms,
- the size of the plot the house sits on
Accessors
House has getters for all instance variables:
- getBedrooms
- getFamilyRoomArea
- getLivingRoomArea
- getPlot
- getStyle
getTotalArea (This method take no parameters, and returns a double value representing the total square feet of the house. Each bedroom is 300 square feet.)
int compareArea(House otherHouse) returns
- a negative value (the exact value doesn't matter--only that it be less than zero) if the current house's total area is smaller than the total area of otherHouse
- a positive number (the exact value doesn't matter--only that it be greater than zero) if the current house's total area is larger than the total area of otherHouse
- 0 if the two houses have exactly the same total area
toString that returns something similar to "House style = Colonial, bedrooms=3, family room area=700.0, living room area=500.0, plot=0.7, square feet=2100.0"
Mutators
House has setters for all instance variables
- setBedrooms
- setFamilRoomArea
- setLivingRoomArea
- setPlot
- setStyle
Tester
Write a class with a main method to test House. Do not put your main method in the House class. Your tester should create at least two House objects, set different values for the Style, Bedrooms, plot, etc. The tester should especially test that compareArea works as expected.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started