我被要求创建一个使用 Array List 实现作业队列的类。我们可以将作业和运行时添加到队列中。作业从 JobInQueue 列表中的队列前面运行,myPendingTime 被减去,完成的作业进入 Finishedjobs 列表。
看起来我们必须为此使用 boolean mutator 方法,但我不确定如何创建此方法。谁能告诉我该怎么做。
/**
* 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 ;
}