Answered step by step
Verified Expert Solution
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 rental Rate is not positive, it should be set to 500.0. Your class should have one constructor that 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 Residence Test 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 cach 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
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