Question: Create a class named Lease with attributes that hold an apartment tenants name, apartment number, monthly rent amount, and term of lease in months. Include
Create a class named Lease with attributes that hold an apartment tenants name, apartment number, monthly rent amount, and term of lease in months. Include a constructor that initializes the name to XXXXX, the apartment number to 0, the rent to 1000, and the term to 12. Include methods to get and set each of the fields. Include a nonstatic method assPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy() to explain the pet fee. Save the class as Lease.java.
Create a driver class named TestLease. In the main method, declare four Lease objects. Create getData() method and call it three times. Within the method, prompt a user for values of each attribute for a Lease, and return a Lease object to the main method where it is assigned to one of the main ()s Lease objects. Do not prompt the user for the values for the fourth Lease object, but let it continue to hold the default values. Create a showValues(Lease ls) method, which displays the data the Lease object passed to the method as a parameter. For Lease1 object, call the addPetFee() method using the passed Lease object, and confirm that the fee explanation statement is displayed. Next, call the showValues() method with each of the other three objects; confirm that three hold the values supplied by users input and one holds the constructor default values. Save the application as TestLease.java.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
