Class EventSimulation
java.lang.Object
|
+--EventSimulation
- public class EventSimulation
- extends Object
Runs an event-driven simulation of a printer being used
and generates statistics concerning the printer's performance.
See constructor for more details.
- Version:
- Mar 3, 2005
- Author:
- Zach Tomaszewski
|
Constructor Summary |
EventSimulation(Printer printer,
int duration,
int minJobInterval,
int maxJobInterval,
int minPages,
int maxPages)
Creates a new simulation to run. |
|
Method Summary |
static void |
main(String[] args)
Creates a new simulation, runs it, and print the results to the screen. |
void |
printStatistics()
Prints the accumulated statistics for this simulation and its printer
to the screen. |
void |
run()
Runs this printer simulation. |
String |
toString()
Provides a snapshot of the current simulation, including the
current job and front parts of the event queue and delayed jobs queue. |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
EventSimulation
public EventSimulation(Printer printer,
int duration,
int minJobInterval,
int maxJobInterval,
int minPages,
int maxPages)
- Creates a new simulation to run. Takes a printer and duration
to run. Generates a series of sample print jobs with a random
amount of time between each job. These jobs are generated with
a random amount of time between them
(minJobInterval <= random time <= maxJobInterval)
and a random number of pages
(minPages <= random pages <= maxPages).
- Parameters:
printer - The printer to test.duration - The time (in seconds) at which to stop assuming
the sim starts at time 0.minJobInterval - The minimum amout of (random) time that should
occur between two consecutive print requests.maxJobInterval - The maximum amount of time between 2 requests.minPages - The minimum number of pages a randomly-generated
job should have.maxPages - The maximum number of pages a job should have.
run
public void run()
throws SimulationHiccupException
- Runs this printer simulation. Generates and stores statistics.
- Throws:
SimulationHiccupException - If something goes wrong during the sim- See Also:
printStatistics()
printStatistics
public void printStatistics()
- Prints the accumulated statistics for this simulation and its printer
to the screen.
toString
public String toString()
- Provides a snapshot of the current simulation, including the
current job and front parts of the event queue and delayed jobs queue.
- Overrides:
toString in class Object
main
public static void main(String[] args)
- Creates a new simulation, runs it, and print the results to the screen.