package guitests;

import guitests.guihandles.GuiHandle;
import javafx.scene.Node;
import javafx.stage.Stage;

//@@author A0143355J
public class UpcomingTaskCardHandle extends GuiHandle {
    private static final String NAME_FIELD_ID = "#name";
    private static final String DATE_ONE_FIELD_ID = "#firstDate";
    private static final String DATE_TWO_FIELD_ID = "#secondDate";

    private Node node;

    protected UpcomingTaskCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node) {
        super(guiRobot, primaryStage, null);
        this.node = node;
    }

    /*
     * Returns the text inside the label
     */
    protected String getTextFromLabel(String fieldId) {
        return getTextFromLabel(fieldId, node);
    }

    /*
     * Returns Task Name inside the UpcomingTaskCard
     */
    protected String getTaskName() {
        return getTextFromLabel(NAME_FIELD_ID);
    }

    /*
     * Returns Deadline date from UpcomingTaskCard
     */
    protected String getDeadline() {
        return getTextFromLabel(DATE_TWO_FIELD_ID);
    }

    /*
     * Returns Start Date from UpcomingTaskCard
     */
    protected String getStartDate() {
        return getTextFromLabel(DATE_ONE_FIELD_ID);
    }

    /*
     * Returns End Date from UpcomingTaskCard
     */
    protected String getEndDate() {
        return getTextFromLabel(DATE_TWO_FIELD_ID);
    }
}

@@ -102,16 +102,308 @@
 e.Stage;
+%0Aimport seedu.tasklist.model.task.DeadlineTask;%0Aimport seedu.tasklist.model.task.EventTask;%0Aimport seedu.tasklist.model.task.FloatingTask;%0Aimport seedu.tasklist.model.task.ReadOnlyDeadlineTask;%0Aimport seedu.tasklist.model.task.ReadOnlyEventTask;%0Aimport seedu.tasklist.model.task.ReadOnlyTask;
 %0A%0A//@@au
@@ -1658,11 +1658,1558 @@
 );%0A    %7D
+%0A%0A    /*%0A     * Returns true if task is the same as the task inside UpcomingTaskCard%0A     */%0A    public boolean isSameTask(ReadOnlyTask task) %7B%0A        String taskType = task.getType();%0A        switch (taskType) %7B%0A        case FloatingTask.TYPE:%0A            return isSameName(task);%0A        case DeadlineTask.TYPE:%0A            return isSameName(task) && isSameDeadline(task);%0A        case EventTask.TYPE:%0A            return isSameName(task) && isSameStartDate(task) && isSameEndDate(task);%0A        default:%0A            return false;%0A        %7D%0A    %7D%0A%0A    /*%0A     * Returns true if task has the same name as task inside UpcomingTaskCard%0A     */%0A    private boolean isSameName(ReadOnlyTask task) %7B%0A        return getTaskName().equals(task.getName().fullName);%0A    %7D%0A%0A    /*%0A     * Returns true if task has the same deadline as task inside UpcomingTaskCard%0A     */%0A    private boolean isSameDeadline(ReadOnlyTask task) %7B%0A        return getDeadline().equals(((ReadOnlyDeadlineTask) task).getDeadlineStringForUpcomingTask());%0A    %7D%0A%0A    /*%0A     * Returns true if task has the same Start Date as task inside UpcomingTaskCard%0A     */%0A    private boolean isSameStartDate(ReadOnlyTask task) %7B%0A        return getStartDate().equals(((ReadOnlyEventTask) task).getStartDateStringForUpcomingTask());%0A    %7D%0A%0A    /*%0A     * Returns true if task has the same End Date as task inside UpcomingTaskCard%0A     */%0A    private boolean isSameEndDate(ReadOnlyTask task) %7B%0A        return getEndDate().equals(((ReadOnlyEventTask) task).getEndDateStringForUpcomingTask());%0A    %7D
 %0A%7D%0A

add isSameTask to UpcomingTaskCardHandle