import java.util.*;

//The Guest class inherits all attributes and methods from it's parent class.
public class Guest extends Person implements SecurityClearance {
	private MyDate startDate;
	private int validPeriod;
	private Boolean hasClearance = false;

	//constructor that simply calls the super constructor
	public Guest(String name, String nric, MyDate birthday, String occupation) {
		super(name, nric, birthday, occupation);	
	}

	//Checks if the clearance 
	public boolean clearanceNotExpired() {
		return hasClearance;
	}

	//Checks if the clearance has expired. If it has, the clearance is revoked. 
	//This function does nothing if the clearance has not expired
	public void updateClearance(MyDate currentDate) {
		int numOfDays = MyDate.dateDifference(startDate, currentDate);
		if (numOfDays > validPeriod)
			revokeClearance();
		else
			return;
	}

	//Issues a new 7 day clearance for the guest
	public void issueClearance(MyDate startDate) {
		this.startDate = startDate;
		validPeriod = 7;
		hasClearance = true;
	}

	//Revokes the clearance of a guest.
	public void revokeClearance() {
		startDate = null;
		hasClearance = false;
	}

	//Renew's the clearance, however, since the guest clearance is temporary, this method is empty.
	public void renewClearance(MyDate startDate) {
		return;
	}

	//Overriden method, this method is implicitly called when System.out.print(Guest) is called.
	public String toString() {
		if (clearanceNotExpired()) {
			return getName() + " has clearance from " + startDate + " lasting " + validPeriod + " days.";
		}
		else {
			return getName() + " no longer has any clearance.";
		}
	}

}

