(a) Develop a Java program to implement the transport hierarchy shown below. The Vehicle class should contain a getDateTime method to get the date and time of the last service in the form of calendar date and time and a getEntertainment method to get the vehicle entertainment e.g. radio, CD.
Each TwoWheelVehicle should contain a method getSpeed to calculate the speed of the two-wheel vehicle.
Each FourWheelVehicle should have methods getSpeed and getSeats to calculate the speed and seat capacity, respectively, of the four-wheel vehicle.
Write a program that creates one object of each of the concrete classes and create an array with references to all of these objects.
The program should print a text description of the object to which each array element refers.
Also, in the loop that processes all the vehicles in the array, determine whether each vehicle is a TwoWheelVehicle or a FourWheelVehicle.
If a vehicle is a TwoWheelVehicle, display its speed and how many times slower it is than the slowest FourWheelVehicle.
If a vehicle is a FourWheelVehicle, display its speed and seat capacity. It should also indicate the date and time in the form of elapsed days, hours, minutes and seconds since the last service.
(b) Develop a multi-threaded Java application as described below Five Data Centre job candidates take part in a data entry test on a 480 minute (8 hour) long day. Each candidate has different abilities:
Rest times are 10 minutes for all job candidates.
(i) Write a multithreaded Java application to simulate a typical days data processing of 215 forms of 400 lines. Display a message in the terminal when each candidate has finished the test.
(ii) Create a job candidate class. The constructor accepts two integers for data entry speed and rest frequency, a reference to a rest object and a String for its name. The job candidate class should also have members that store a line count and duration in minutes. It should stop once the test is finished (i.e. after 480 minutes).
(iii) The area for resting can only be occupied by one job candidate at a time and it is occupied at the start of the test for 5 minutes. This will require synchronisation between threads and the use of locks. If a job candidate needs to take a rest but another candidate is already in the rest area they must skip their rest until their next scheduled one. As a result, their performance suffers and their throughput reduces by 50% until they have the opportunity to break again.