Class Printer

java.lang.Object
  |
  +--Printer

public class Printer
extends Object

Represents a printer in a simulation. Also records certain statistics.

Version:
Mar 3, 2005
Author:
Zach Tomaszewski

Constructor Summary
Printer(int pageRate, int paperCapacity)
          Creates a new printer
 
Method Summary
(package private)  int getPrintTime(int pages)
          Returns how long it will take to print the given number of pages, but does not actually print them.
 int print(int pages)
          Tells this printer to simulate printing a print job.
protected  void reset()
          Resets this printer, setting all statistics to zero.
 String toString()
          Returns the settings and statistics of this printer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Printer

public Printer(int pageRate,
               int paperCapacity)
Creates a new printer
Parameters:
pageRate - How many seconds it takes this printer to print one page
paperCapacity - How many pages this printer holds when its paper tray is full
Method Detail

reset

protected void reset()
Resets this printer, setting all statistics to zero.

getPrintTime

int getPrintTime(int pages)
Returns how long it will take to print the given number of pages, but does not actually print them.
Parameters:
pages - Number of pages to "print"
Returns:
Number of seconds it will take to "print" that many pages
Throws:
IllegalArgumentException - if you try to print < 0 pages.

print

public int print(int pages)
          throws IllegalArgumentException
Tells this printer to simulate printing a print job.

Updates all the relevant stats for this printer concerning number of jobs (++), total pages printed (+= pages), current pages in the printer tray (-= pages), etc.

Returns how long it takes to print the given number of pages at this printer's print rate.

Parameters:
pages - Number of pages to "print"
Returns:
Number of seconds it takes to "print" that many pages
Throws:
IllegalArgumentException - if you try to print < 0 pages.

toString

public String toString()
Returns the settings and statistics of this printer.
Overrides:
toString in class Object