forked from nusCS2113-AY1920S1/PersonalAssistant-Duke
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from leowyh/master
Added B-DoWithinPeriodTasks with unit testing
- Loading branch information
Showing
5 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package task; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Task containing information of a Task to be done within a period. | ||
*/ | ||
public class WithinPeriodTask extends Task implements Serializable { | ||
protected String start; | ||
protected String end; | ||
|
||
/** | ||
* Creates a WithinPeriodTask instance and initialises the required attributes. | ||
* @param description Description of the task. | ||
* @param start Start time of the task in format "dd/MM/yyyy HHmm". | ||
* @param end End time of the task in format "dd/MM/yyyy HHmm". | ||
*/ | ||
public WithinPeriodTask(String description, String start, String end) { | ||
super(description); | ||
this.start = start; | ||
this.end = end; | ||
} | ||
|
||
/** | ||
* Returns a string status of the WithinPeriodTask task. | ||
* @return The task's status icon, description, start and end times. | ||
*/ | ||
@Override | ||
public String giveTask() { | ||
return "[W]" + super.giveTask() + "(between: " + start + " and " + end + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import org.junit.jupiter.api.Test; | ||
import task.WithinPeriodTask; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class WithinPeriodTaskTest { | ||
|
||
@Test | ||
public void WithinPeriodTaskTest() { | ||
WithinPeriodTask withinPeriodTask = new WithinPeriodTask("collect certificate ", "02/12/2019 1800", "05/12/2019 1500" ); | ||
assertEquals(withinPeriodTask.giveTask(), "[W][✘] collect certificate (between: 02/12/2019 1800 and 05/12/2019 1500)"); | ||
} | ||
} |