package schedule;
import time.Time;
public class Lecture{

	private String name;
	private boolean konz;
	private Time k,b;

	private Lecture(String n, boolean ko, Time k, Time b){
		name=n;konz=ko;this.k=k;this.b=b;
	}

	public boolean isConsultation(){
		return konz;
	}
	public String getName(){
		return name;
	}

	public static Lecture create(String n, boolean ko, Time k, Time b){
		if(k!=null&&b!=null && k.before(b))return new Lecture(n,ko,k,b);
		else return null;
	}

	public boolean overlapsWith(Lecture that){
		return this==that || k.isSame(that.k) || b.isSame(that.b) || k.between(that.k,that.b) || b.between(that.k,that.b);
	}

	public String show(){
		String r=name;
		if(konz)r+=" (CONSULTATION)";
		r+=" ";
		r+=k.show();
		r+=" - ";
		r+=b.show();
		return r;
	}

	public static Lecture parseLecture(String n, String k, String b){
		boolean konz=n.contains("(CONSULTATION)");
		String name=n.replace(" (CONSULTATION)","");
		Time kezd=Time.parseTime(k);
		Time bef=Time.parseTime(b);
		return create(name,konz,kezd,bef);
	}
}
