package seedu.tasklist.testutil;

import java.sql.Date;

import seedu.tasklist.model.tag.UniqueTagList;
import seedu.tasklist.model.task.*;

/**
 * A mutable Task object. For testing only.
 */
public class TestTask implements ReadOnlyTask, Comparable<TestTask> {

    private TaskDetails taskDetails;
    private int uniqueID;
    private EndTime endTime;
    private StartTime startTime;
    private Priority priority;
    private UniqueTagList tags;
    private boolean isComplete;
    private boolean isRecurring;
    private String recurringFrequency;

    public TestTask() {
        tags = new UniqueTagList();
    }

    public void setTaskDetails(TaskDetails taskDetails) {
        this.taskDetails = taskDetails;
    }

    public void setUniqueID(int uniqueID) {
        this.uniqueID = uniqueID;
    }

    public void setEndTime(EndTime endTime) {
        this.endTime = endTime;
    }

    public void setStartTime(StartTime startTime) {
        this.startTime = startTime;
    }
    
    public void setPriority(Priority priority) {
        this.priority = priority;
    }
    
    public void setRecurringFrequency(String frequency) {
    	switch (frequency) {
	    case "daily": case "weekly": case "monthly": case "yearly": 
            this.isRecurring = true;
            this.recurringFrequency = frequency;
            break;
        default:
            this.isRecurring = false;
            this.recurringFrequency = "";
    	}
    }

    @Override
    public TaskDetails getTaskDetails() {
        return taskDetails;
    }

    @Override
    public StartTime getStartTime() {
        return startTime;
    }

    @Override
    public EndTime getEndTime() {
        return endTime;
    }
    
    @Override
    public String getRecurringFrequency() {
    	return this.recurringFrequency;
    }

    @Override
    public int getUniqueID() {
        return uniqueID;
    }
    
    public void markAsComplete() {
        isComplete = true;
    }

    @Override
    public UniqueTagList getTags() {
        return tags;
    }

    @Override
    public String toString() {
        return getAsText();
    }

    public String getAddCommand() {
        StringBuilder sb = new StringBuilder();
        sb.append("add " + this.getTaskDetails() + " ");
        if(!this.getStartTime().isMissing()){
        	sb.append("at " + this.getStartTime().toCardString() + " ");
        }
        if(!this.getEndTime().isMissing()){
        	sb.append("by " + this.getEndTime().toCardString() + " ");
        }
        sb.append("p/" + this.getPriority() + " ");
        this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " "));
        return sb.toString();
    }

    @Override
    public boolean isComplete() {
        return isComplete;
    }

    @Override
    public Priority getPriority() {
        return priority;
    }

	@Override
	public boolean isFloating() {
		return endTime.isMissing()&&startTime.isMissing();
	}
	
	@Override
	public boolean isRecurring() {
		return this.isRecurring;
	}

	@Override
	public boolean isOverDue() {
		if(!isFloating()){
			if(!endTime.endTime.getTime().equals(new Date(0))){
				return endTime.endTime.getTimeInMillis() < System.currentTimeMillis();
			}
			else return false;
		}
		else 
			return false;
	}
	
	@Override
	public int compareTo(TestTask o){
		if(!this.startTime.equals(o.getStartTime())){
			return this.startTime.compareTo(o.getStartTime());
		}
		else {
			return this.priority.compareTo(o.getPriority());
		}
	}
}

@@ -48,16 +48,43 @@
 ql.Date;
+%0Aimport java.util.Calendar;
 %0A%0Aimport
@@ -3535,11 +3535,702 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A    public boolean hasStartTime() %7B%0A        return new StartTime((long)0).equals(startTime);%0A    %7D%0A    %0A    public boolean hasEndTime() %7B%0A        return new EndTime((long)0).equals(endTime);%0A    %7D%0A%09%09%0A%09@Override%0A    public boolean isEvent() %7B%0A%09%09return hasStartTime() && hasEndTime();%0A    %7D%0A    %0A%09@Override%0A    public boolean isToday() %7B%0A    %09if(!hasEndTime()) return false;%0A    %09return endTime.endTime.get(Calendar.DAY_OF_YEAR) == Calendar.getInstance().get(Calendar.DAY_OF_YEAR);%0A    %7D%0A    %0A%09@Override%0A    public boolean isTomorrow() %7B%0A    %09if(!hasEndTime()) return false;%0A    %09return endTime.endTime.get(Calendar.DAY_OF_YEAR) == Calendar.getInstance().get(Calendar.DAY_OF_YEAR) - 1;%0A    %7D
 %0A%7D%0A

added different is_ statements for different task states