forked from nusCS2113-AY1920S1/duke
-
Notifications
You must be signed in to change notification settings - Fork 0
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 nusCS2113-AY1920S1#20 from saradj/B-Snooze
[CS2113-T14-2]-saradj-B-Snooze
- Loading branch information
Showing
10 changed files
with
174 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package duke.command; | ||
|
||
import duke.exception.DukeException; | ||
import duke.parser.Parser; | ||
import duke.storage.Storage; | ||
import duke.task.Task; | ||
import duke.task.TaskList; | ||
import duke.ui.Ui; | ||
|
||
import java.util.Date; | ||
|
||
public class Snooze extends Command { | ||
|
||
private int taskNb; | ||
private String until; | ||
private Date date; | ||
|
||
public Snooze(String taskNb, String until){ | ||
this.taskNb = Integer.parseInt(taskNb.trim())-1; | ||
this.until=until; | ||
this.date= Parser.getDate(until); | ||
} | ||
|
||
@Override | ||
public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { | ||
if (taskNb < taskList.size() && taskNb >= 0) { | ||
if(taskList.getTask(taskNb).isDone()) | ||
throw new DukeException("Seems like you've already finished that task, no need to snooze it now"); | ||
taskList.changeTaskDate(taskNb, until); | ||
ui.showChangedDate(Parser.getDateString(date, until),taskList.getTask(taskNb).toString() ); | ||
storage.changeContent(taskNb); | ||
} else | ||
throw new DukeException("Enter a valid task number after snooze, between 1 and " + taskList.size()); | ||
} | ||
} | ||
|
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
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,9 @@ | ||
/** | ||
* | ||
*/ | ||
/** | ||
* @author Sara | ||
* | ||
*/ | ||
module duke { | ||
} |
Empty file.