Class JobSimulation

java.lang.Object
  |
  +--JobSimulation

public class JobSimulation
extends Object

Runs a simulation of a printer being used and generates statistics concerning the printer's performance. Uses a job-based (rather than event-driven) approach.

Version:
Apr 07, 2005
Author:
Zach Tomaszewski

Constructor Summary
JobSimulation(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 time and next job.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobSimulation

public JobSimulation(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.
Method Detail

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 time and next job.
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.