59 lines
1.2 KiB
Java
59 lines
1.2 KiB
Java
public class P2_PrinterHead{
|
|
|
|
private char mode = 'M';
|
|
private String jobId;
|
|
private int timeRemaining = 0;
|
|
|
|
private int id;
|
|
|
|
public P2_PrinterHead(int idInput)
|
|
{
|
|
//Nothing to set up.
|
|
id = idInput;
|
|
}
|
|
|
|
public synchronized void print(P2_Jobs jobInput, int[] time)
|
|
{
|
|
//Set the details of the current job
|
|
jobId = jobInput.getId();
|
|
mode = jobInput.getJobType();
|
|
int startTime = time[0];
|
|
|
|
//Wait (and delay the thread) one second per page of the job
|
|
for(int i = 0; i<jobInput.getPages(); i++)
|
|
{
|
|
try
|
|
{
|
|
Thread.sleep(1000);
|
|
time[0]++;
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
//Don't actually care
|
|
}
|
|
}
|
|
System.out.println("("+startTime+") "+jobInput.getId()+" uses head "+getId()+"(time: "+jobInput.getPages()+")");
|
|
}
|
|
|
|
//Getters
|
|
|
|
public int getId()
|
|
{
|
|
return id;
|
|
}
|
|
|
|
public String getJobId()
|
|
{
|
|
return jobId;
|
|
}
|
|
|
|
public char getMode()
|
|
{
|
|
return mode;
|
|
}
|
|
|
|
public int getTimeRemaining()
|
|
{
|
|
return timeRemaining;
|
|
}
|
|
} |