Supply spaceships of different designs and capabilities have been developed to support a human colony on the moon. The ships embark continually from a spaceport in low earth orbit to the moon. On arrival the ships undock, unload their cargo and undergo refuelling and maintenance in 'The RF Centre' (RF) before embarking on the return journey. The bulk of the time at spaceport is spent in RF but only a single spaceship can be accommodated in RF at any one time.
Five competing companies have manufactured distinct ships to service the colony - each ship travels at different speeds, has a different payload capacity and requires differing periods in RF (relative to the fastest ship):
Follow the subsections below (together with your own model) to write a multithreaded Java application to simulate the performance of the ships in competition with each other over 3 years. Include screenshots of the output of your program in your answer and paste the Java code of your final solution in an appendix to the document.
(a)Create a Ship class. The constructor for the ship class should accept a reference to the RF centre object, an identifier string for the ship's name ("ShipType 1", for example) and three numbers identifying the unique characteristics of each of the ships; the maximum payload in KG, the maximum days of a single journey to travel to the colony and the maximum days in the RF centre.
The ship should have members that store a count of the total number of trips, total time spent travelling and in maintenance [RF center].
(b)Each ship must have a run() method which advances the time elapsed "travelling" by 1 day of simulation time for each 10ms of actual time. A random number generator should be used to calculate the duration of each trip within the limits specified by the ship type. When the end of the competition has been reached (3 years), a toString method should display the total number of trips, count of days spent travelling and days spent in the RF centre. The total cargo weight delivered should also be displayed
(c)Display messages in the terminal stating that the simulation has started, notifying the user if an RF session is taking place and display each agent's toString method at the end of the simulation. Calculate and display the total payload transported.
(d)Create an RF_Centre class. It should have a method to "refuel and maintain" a space ship and return the actual RF duration in days. Ensure only one ship can access the RF Centre at any one time.
(e)Create a SpaceshipCompetition class that has a main method that creates and starts the threads.
(f)You want to ensure that all space ships depart at the same time when the competition starts. Write a new class called "Competition" that has methods to:
Modify the CompetitionMain and Ship classes accordingly.