package os;

import readinstruction.ReadInstruction;
import readinstruction.ReadInstructionImpl;
import scheduler.Scheduler;
import utils.Clock;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

/**
 * Created by Karol on 2017-04-20.
 */
public class OSBuilder {
    private Clock systemClock;
    private Scheduler systemScheduler;
    private Queue<ReadInstruction> readQueue;
    private boolean consoleFlag;

    public OSBuilder withReadInstructions(ArrayList<ReadInstruction> readQueue){
        this.readQueue = new LinkedList<>();
        for (ReadInstruction instruction : readQueue) this.readQueue.add(instruction);
        return this;
    }

    public OSBuilder withInstructionsSource(String filePath){
        Queue<ReadInstruction> result = new LinkedList<>();
        File inputFile = new File(filePath);
        try(FileReader fileIn = new FileReader(inputFile);
            Scanner dataIn = new Scanner(fileIn)){
            while(dataIn.hasNextLine()){
                String[] processText = dataIn.nextLine().split(",");
                result.add(new ReadInstructionImpl(
                        UUID.fromString(processText[0]),
                        Integer.parseInt(processText[1]),
                        Integer.parseInt(processText[2]),
                        Boolean.parseBoolean(processText[3])));
            }
            this.readQueue = result;
        } catch (IOException e){
            throw new IllegalArgumentException("File not found or data corrupted");
        }
        return this;
    }

    public OSBuilder withClock(Clock systemClock){
        this.systemClock = systemClock;
        return this;
    }

    public OSBuilder withSystemScheduler(Scheduler systemScheduler){
        this.systemScheduler = systemScheduler;
        return this;
    }

    public OSBuilder withConsoleOutput(){
        this.consoleFlag = true;
        return this;
    }

    public OperatingSystemImpl build() {
        return new OperatingSystemImpl(
                this.systemClock,
                this.systemScheduler,
                this.readQueue,
                this.consoleFlag
        );
    }
}

@@ -1077,17 +1077,17 @@
 .split(%22
-,
+;
 %22);%0A    

Fix parsing method