/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package IntermediaryCode;

/**
 *
 * @author EUGENIO CARVALHO
 */
public class Interval {

    public int Start;
    public int End;
    public String Register = "";
    protected boolean persist;

    Interval(int start, int end) {
        Start = start;
        End = end;
        persist = false;
    }

    public int getStart() {
        return Start;
    }

    public void setStart(int Start) {
        this.Start = Start;
    }

    public int getEnd() {
        return End;
    }

    public void setEnd(int End) {
        this.End = End;
    }

    public String getRegister() {
        return Register;
    }

    public void setRegister(String Register) {
        this.Register = Register;
    }

    boolean Alive(int position) {
        return position <= End;
    }

    void Close(int position) {
        End = position;
    }

    @Override
    public String toString() {
        return "[" + Start + ", " + End + ", " + Register + "]";
    }

    public boolean Inside(int i) {
        return Start <= i && i <= End;
    }

    public boolean RegisterDefined() {
        return !Register.equals("");
    }

    public boolean Perisist() {
        return this.persist;
    }

    public boolean Perisist(boolean p) {
        return this.persist = p;
    }

}
