Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part A Implement the class named Lease with fields that hold an apartment tenant s name ( name ) , apartment number ( aptNumber )
Part A
Implement the class named Lease with fields that hold an apartment tenants name name apartment number aptNumber monthly rent amount rent and term of the lease in months term
Include a default constructor that initializes the name to XXX the apartment number to the rent to and the term to
Include methods to get and set each of the fields. Include a nonstatic method named addPetFee that adds $ to the monthly rent value and calls a static method named explainPetPolicy that explains the pet fee.
Part B
Create a class named TestLease whose main method declares four Lease objects named lease lease lease and lease
Create a getData method that prompts a user for values for each field for a Lease, and return a newly constructed Lease object to the main method where it is assigned to one of mains first three Lease objects. Do not prompt the user for values for the fourth Lease object, but let it hold the default values.
After the four Lease objects have been assigned values, pass the lease object to a showValues method that displays the data.
The data should be displayed in the following format:
Your lease results:
Name : Jane Doe
Apartment :
Rent :
Term :
Then call the addPetFee method with the lease object, and confirm that the fee explanation statement is displayed. Next, call the showValues method for the lease object again and confirm that the pet fee has been added to the rent.
Finally, call the showValues method with each of the other three objects. Confirm that two hold the values you supplied as input and one holds the constructor default values.
Part A
Implement the class named Lease with fields that hold an apartment tenants name name apartment number aptNumber monthly rent amount rent and term of the lease in months term
Include a default constructor that initializes the name to XXX the apartment number to the rent to and the term to
Include methods to get and set each of the fields. Include a nonstatic method named addPetFee that adds $ to the monthly rent value and calls a static method named explainPetPolicy that explains the pet fee.
Part B
Create a class named TestLease whose main method declares four Lease objects named lease lease lease and lease Create a getData method that prompts a user for values for each field for a Lease, and return a newly constructed Lease object to the main method where it is assigned to one of mains first three Lease objects. Do not prompt the user for values for the fourth Lease object, but let it hold the default values.
After the four Lease objects have been assigned values, pass the lease object to a showValues method that displays the data. Then call the addPetFee method with the lease object, and confirm that the fee explanation statement is displayed.
Next, call the showValues method for the lease object again and confirm that the pet fee has been added to the rent.
Finally, call the showValues method with each of the other three objects. Confirm that two hold the values you supplied as input and one holds the constructor default values.
Task #: Implement the Lease class and its member variables
Task #: Define the Lease class constructor
Task #: Include the se methods for the Lease class
Task #: Include the get methods for the Lease class
Task #: Implement the addPetFee method in the Lease class
Task #: Implement the explainPetPolicy method in the Lease class
Task #: Create the TestLease class with a main declaring four Lease objects
Task #: Define the getData method
Task #: The showValues method takes a Lease object argument and displays its data
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