Answered step by step
Verified Expert Solution
Link Copied!

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 0, the rent to 1000, and the term to 12.
Include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 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 lease1, lease2, lease3, and lease4.
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 main()s 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 lease1 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 : 21
Rent : 1654.0
Term : 13
Then call the addPetFee() method with the lease1 object, and confirm that the fee explanation statement is displayed. Next, call the showValues() method for the lease1 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 0, the rent to 1000, and the term to 12.
Include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 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 lease1, lease2, lease3, and lease4. 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 main()s 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 lease1 object to a showValues() method that displays the data. Then call the addPetFee() method with the lease1 object, and confirm that the fee explanation statement is displayed.
Next, call the showValues() method for the lease1 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 #01: Implement the Lease class and its member variables
Task #02: Define the Lease class constructor
Task #03: Include the se methods for the Lease class
Task #04: Include the get methods for the Lease class
Task #04: Implement the addPetFee() method in the Lease class
Task #06: Implement the explainPetPolicy() method in the Lease class
Task #07: Create the TestLease class with a main() declaring four Lease objects
Task #08: Define the getData() method
Task #09: 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

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

Students also viewed these Databases questions