Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Residence that a real estate business might use to represent a residential unit that they rent or sell to customers. A

Create a class called Residence that a real estate business might use to represent a residential unit that they rent or sell to customers. A Residence should include three pieces of private information as instance variables the type of residence (a String), number of availableUnits (an int) and the rentalRate per unit (a double).

Provide a set and a get method for each instance variable. For the setters: if the availableUnits is not positive, it should be set to 1. If the rentalRate is not positive, it should be set to 500.0. Your class should have one constructorthat properly initializes the three instance variables. In addition, provide a method named getTotalRent() that calculates the total rent amount (i.e. multiplies the availableUnits by the rentalRate per unit), then returns the result as a double value.

Write an application named ResidenceTest to test Residence class. In the ResidenceTest do the following:

  1. Create a residence instance for the unit: 5-Bed Villa, availableUnits =10 and rentalRate for each one is 13250.0 Rials.
  2. Display details of the above residences and their total rent amount, properly labeled (show two digits after the decimal point of rentalRate and total rent amount).
  3. Create another residence instance for the unit: Studio Flat, availableUnits=15 and rentalRate for each one is 1000.0 Rials (yes, the value is negative, to test your code).
  4. Display the type and the total rent amount for this instance.
  5. Using a getter and a setter, set the rentalRate for the Studio Flat to be 30% of the rentalRate for a 5-Bed Villa. (Hint 30% of something means 0.30*something).
  6. Re-display the type and the total rent amount of the second instance after setting the rentalRate.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

Is how things are said consistent with what is said?

Answered: 1 week ago

Question

Do you currently have a team agreement?

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago