public class Process {
    
    private String id;
    private int arrive;
    private int execSize;
    private int tickets;

    //Post Run details
    private int turnAroundTime = -1;
    private int waitTime = -1;
    private int startTime = -1;
    private int endTime= -1;

    private int remainingTime;
     

    //Constructors
    public Process(){
    }

    public Process(String idInput, int arriveInput, int execSizeInput, int ticketsInput) {
        id = idInput;
        arrive = arriveInput;
        execSize = execSizeInput;
        tickets = ticketsInput;
        remainingTime = execSizeInput;
    }

    //Setters
    public void setId(String idInput){
        id = idInput;
    }
    public void setArrive(int arriveInput){
        arrive = arriveInput;
    }
    public void setSize(int execSizeInput){
        execSize = execSizeInput;
        remainingTime = execSizeInput;
    }
    public void setTickets(int ticketsInput){
        tickets = ticketsInput;
    }

    /**
     * Saves the time that the process first started running
     * Only saves if there isn't already a valid time stored
     * (ie, startTime == -1)
     * @param timeInput
     */
    public void saveStartTime(int timeInput)
    {
        if(startTime == -1)
        {
            startTime=timeInput;
        }
    }
    public void saveEndTime(int timeInput)
    {
        endTime=timeInput;
    }

    public void saveTurnTime(){
        turnAroundTime = endTime-arrive;
    }

    public void saveWaitTime(){
        waitTime = startTime - arrive;
    }


    //Getters
    public String getId(){
        return id;
    }
    public int getArrive(){
        return arrive;
    }    
    public int getExecSize(){
        return execSize;
    }  
    public int getTickets(){
        return tickets;
    }  
    public int getTurnTime(){
        return turnAroundTime;
    }
    public int getWaitTime(){
        return waitTime;
    }   
    public int getStartTime()
    {
        return startTime;
    }
    public int getEndTime()
    {
        return endTime;
    }
    public int getRemainingTime()
    {
        return remainingTime;
    }


    //Functions
    public void runForOneTick(boolean isRunning)
    {
        if(isRunning)
        {
            remainingTime--;
        }
        else
        {
            if(waitTime==-1)
            {
                waitTime=1;
            }
            else
            {           
                waitTime++;
            }   
        }
    }
    
    public boolean isDone()
    {
        if (remainingTime <= 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public void reset()
    {
        turnAroundTime = -1;
        waitTime = -1;
        remainingTime = execSize;
        startTime = -1;
        endTime = -1;
    }
}