Question: In java Write a class encapsulating the concept of a house, assuming a house has the following attributes: value (in dollars) , a city location

In java

Write a class encapsulating the concept of a house, assuming a house has the following attributes: value (in dollars) , a city location , and number of bedrooms .

Your class name should be House and your code should be in a file called House.java. You will need to create this file ( remember to NOT check the box to create a main method ). In this class, i nclude :

P rivate instance variables for the previously - mentioned attributes

A default constructor

An overloaded constructor

A ccessor and mutator methods (i.e., get and set methods )

The toString method

The equals method

Your default constructor should typically initialize the instance variables to some default values that you feel are appropriate (lets just go with a $100,000, 2 - bedroom home in Azu sa ) . The overloaded constructor should pass in values for value, city location and number of bedrooms which are used to initialize the class instance variables.

Also, use the pr ovided template file (CS220_Lab11 .java) as your client class to test all the methods in your class. So, you would want to test the default and overloaded constructors, as well as accessors, mutators, toString and equals method s . Since this is the first time youve ever thought about creating a client to test a user - defined class , w eve included a sample of how you should do this below.

Expected Output

Lab 11 , Problem 3

This house is in Azusa, is worth $100,000 and has 2 bedrooms.

This house is in Pasadena, is worth $1,400,000 and has 6 bedrooms.

Before modifying big house using setters:

Big house value: $1,400,000

Big house locati on: Pasadena

Big house bedrooms: 6

After modifying big house using setters:

Big house value: $3,200,000

Big house location: Hollywood

Big house bedrooms: 14

The default house and big house are DIFFERENT houses!

The identical big house and big house are the SAME houses!

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!