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 #11 from gowgos5/B-ViewSchedules
[CS2113-T14-1]-gowgos5-B-ViewSchedules
- Loading branch information
Showing
6 changed files
with
144 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package duke.command; | ||
|
||
import duke.DukeContext; | ||
import duke.exception.DukeException; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeParseException; | ||
|
||
/** | ||
* Class responsible for executing Command to view the scheduled Tasks on a specified date. | ||
* | ||
* @author Pang Jia Jun Vernon | ||
*/ | ||
public class ViewCommand extends ArgCommand { | ||
private static final DateTimeFormatter PAT_DATE = DateTimeFormatter.ofPattern("d/M/yyyy"); | ||
|
||
private LocalDate date; | ||
|
||
/** | ||
* Creates a new Command object that can be executed to view the scheduled Tasks on a specified date. | ||
*/ | ||
public ViewCommand() { | ||
emptyArgMsg = "Please give me a date to work with!"; | ||
} | ||
|
||
@Override | ||
public void parse(String inputStr) throws DukeException { | ||
super.parse(inputStr); | ||
|
||
try { | ||
date = LocalDate.parse(arg, PAT_DATE); | ||
} catch (DateTimeParseException excp) { | ||
throw new DukeException("Date must be given as e.g. " + LocalDateTime.now().format(PAT_DATE) + "."); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute(DukeContext ctx) throws DukeException { | ||
String scheduleStr = "Here are your tasks for " + arg + ":"; | ||
ctx.ui.print(scheduleStr + ctx.taskList.listSchedule(date)); | ||
} | ||
} |
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