Question: please help within 1 hour Given the following UML class diagram in Figure 1, write a complete Java programs based on the instruction given below.

 please help within 1 hour Given the following UML class diagramin Figure 1, write a complete Java programs based on the instructiongiven below. Car - carName: String - carld: int - rentPer Hour:double; Rental - rentId : int - car: Car - customer :Customer - unit: int + Car(String, int, double) + getName(): String +

please help within 1 hour

Given the following UML class diagram in Figure 1, write a complete Java programs based on the instruction given below. Car - carName: String - carld: int - rentPer Hour: double; Rental - rentId : int - car: Car - customer : Customer - unit: int + Car(String, int, double) + getName(): String + getRent(): double + Rental(int, Car, Tenant, int) + calcTotalRent(): double + toString(): String Tenant - tenantId: int -tenant Name: String TestRental + Tenant(int, String) + getName(): String + main(String[]):void Figure 1: UML class diagram a) Write a class Car with the following methods: (1) Write constructor for class Car that initializes carName, carid and rentPerHour instance variables through parameter passing. (ii) Write suitable code for the accessor methods. b) Write a class Tenant with the following methods: (1) Write constructor for class Tenant that initializes tenantId and tenantName instance variables through parameter passing. (ii) Write suitable code for the getName() accessor method. c) Write a class Rental with the following methods: [16 Marks] (1) Write constructor for class Rental that initializes rentid; tenant, car and hour instance variables through parameter passing. (ii) Write method calcTotalRent () which able to return the total value of car rent times with hour. (ii) Write method toString() which creates a string of rental information. d) Write a class TestRental that only has main() method with the following codes: [17 Marks] (1) Create three (3) objects of class Car using the constructor with the specified information as shown in Table 1. (ii) Create three (3) objects of class Tenant using the constructor with the specified information as shown in Table 2. (iii) Create a Vector or ArrayList object named rental to store the created objects of class Rental with the specified information as shown in Table 3. (iv) Use the for loop to print the list of rentals using toString() method. The program should produce the output as shown in Figure 2. Table 1 Object Name Car Id carl 231 car2 345 car3 654 Car Name Estima Vios Viva Rent (Per hour) 150.00 80.00 50.00 Table 2 Object Name Tenant Id tenant 1 90 tenant2 91 tenant3 95 Tenant Name Raihana Boo Lee Sita A/P Roki Table 3 Rental Id Tenant Car 1 2 3 tenant1 tenant2 tenant3 car1 car2 car3 Rental Duration (in Hour) 2 4 5 List of rentals: Rental: 1 : 1 Tenant: Raihana Car: Estima Hours: 2 Rental per Hour: 150.0 Total rental: 300.0 Rental: 2 Tenant: Boo Lee Car: Vios Hours: 4 Rental per Hour: 80.0 Total rental: 320.0 Rental: 3 Tenant: Sita A/P Roki Car: Viva Hours: 5 Rental per Hour: 50.0 Total rental: 250.0 Figure 2 : Output of the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!