Question: Object - Oriented Approach Problem Part 2 I asked for part 1 and i am continue asking. The language is Java. Implement a Ticket class

Object-Oriented Approach Problem Part2 I asked for part1 and i am continue asking. The language is Java. Implement a Ticket class with the following UML diagram.
When a vehicle is parked, a Ticket object is created containing the vehicle itself and entry
date of the vehicle.
You have to use this keyword in the implementation of the constructor.
Consider the following example which demonstrates the creation of a Ticket object:
Ticket ticket = new Ticket (vehicle, entryDate);
CalculatePrice method takes a double value of hourly price and exit date of the
vehicle, then calculates the price of parking service by considering how many hours the
vehicle is parked and the size of the vehicle. The totalPrice field of the Ticket
object should also be updated in this method.
You can calculate the parking cost with the following formula:
Parking cost = vehicleSize * hourlyPrice * numberOfHours
It should be noted that the numberOfHours value should be rounded up.(Example: If a car
parked for 3 hours and 20 minutes, then you should charge the parking cost with 4 hours.)
The getTicketInfo method returns a string value based on two conditions.
If the vehicle does not exit from the car park up to now, then the string should
have the vehicle's plate number and entry date.
Example:
Ticket Info
Plate Number : 34 CSE1141
Entry : Fri Dec 1511:03:48 EET 2017
If the vehicle exited from the car park, then the string should have the vehicle's
plate number, entry date, exit date, and the total price for parking service.
Example:
Ticket Info
Plate Number : 34 CSE1141
Entry : Fr1 Dec 1511:03:48 EET 2017
Exit : Fri Dec 1516:03:48 EET 2017
Hour : 5
Fee : 50.0TLs
getVehicle method returns the Vehicle object of the Ticket object.
getPrice method returns the totalPrice field of the Ticket object.
 Object-Oriented Approach Problem Part2 I asked for part1 and i am

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 Programming Questions!