Objective: Write the Singleton classes for the course project in Java or C++.
Workflow note: This page collects your solution. After you submit, the next page will display exactly what you entered and provide any follow-up guidance for the project workflow.
For the simulation you will need a shared clock so that time is consistent across the different classes. This is not a real-time clock; it is a simulated clock. There must be only one instance so every class reads the same time.
int field named currentTime initialized to 0.
Provide a getter method that returns currentTime, but do not provide a setter.
currentTime:int
endOfTime:int
+Time(endOfTime:int)
+run():void
Time class (UML)
endOfTime that stores the number of seconds the clock should run.
Set endOfTime in the constructor.
run() method that increments currentTime by 1 until it reaches endOfTime.
In other words, run() counts from the initial time value up to the end of the simulation.
Write this Time (or Clock) class as a Singleton.
In the text area below, type your answer and click Submit.