package scheduler;

import os.OperatingSystem;
import readinstruction.ReadInstruction;

import java.util.LinkedList;
import java.util.Queue;

/**
 * Created by Karol on 2017-04-20.
 */
public class FcfsScheduler implements Scheduler {
    private Queue<ReadInstruction> waitingQueue;
    private OperatingSystem parentOs;

    public FcfsScheduler(){
        this.waitingQueue = new LinkedList<>();
    }

    @Override
    public void setOs(OperatingSystem parentOs) {
        this.parentOs = parentOs;
    }

    @Override
    public void push(ReadInstruction instruction) {
        this.waitingQueue.add(instruction);
    }

    @Override
    public String getName() {
        return null;
    }

    @Override
    public void update(int time) {

    }
}

@@ -314,16 +314,46 @@
 arentOs;
+%0A    private int headPosition;
 %0A%0A    pu
@@ -422,16 +422,47 @@
 st%3C%3E();%0A
+        this.headPosition = 0;%0A
     %7D%0A%0A 
@@ -803,16 +803,403 @@
 time) %7B%0A
+        if (this.waitingQueue.peek().getReadAddress() %3E this.headPosition) this.headPosition++;%0A        if (this.waitingQueue.peek().getReadAddress() %3C this.headPosition) this.headPosition--;%0A        if (this.waitingQueue.peek().getReadAddress() == this.headPosition)%7B%0A            this.waitingQueue.peek().read(time);%0A            this.parentOs.push(this.waitingQueue.remove());%0A        %7D
 %0A    %7D%0A%7D

Implement update method in FcfsScheduler