I was asked to create a class that implement a queue of jobs using Array List.
We can add jobs and runtime to the queue. A job runs from the front of the queue in the JobInQueue list, myPendingTime gets subtracted and the completed job goes to the Finishedjobs list.
It looks like we have to use boolean mutator method for this but I am not sure how to create this method.
could anyone tell me how to do this.
/**
* runs the first job on the queue if there is enough time on the clock.
*/
public boolean runJob()
{
boolean jobDone = runJob();
if(myJobInQueue.isEmpty() && myDuration > myPendingTime){
myDuration-= myPendingTime;
myJobInQueue.remove(0);
myFinishedJobs.add(myJobInQueue.get(0));
System.out.println("The job runing is : "+ myJobInQueue.get(0));
jobDone=true;
}
return jobDone ;
}
Based on your inputs, please find the updated program below:
Also I believe you want to check,
myJobInQueueis not empty i.e.if(!myJobInQueue.isEmpty() && myDuration > myPendingTime).