forked from CS2113-AY1819S2-T08-3/main
-
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 #4 from CS2113-AY1819S2-T08-3/master
Merge
- Loading branch information
Showing
23 changed files
with
713 additions
and
165 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,52 @@ | ||
1:Vacation | ||
2:Vacation | ||
3:Week 1 | ||
4:Week 2 | ||
5:Week 3 | ||
6:Week 4 | ||
7:Week 5 | ||
8:Week 6 | ||
9:Recess Week | ||
10:Week 7 | ||
11:Week 8 | ||
12:Week 9 | ||
13:Week 10 | ||
14:Week 11 | ||
15:Week 12 | ||
16:Week 13 | ||
17:Reading Week | ||
18:Examination Week | ||
19:Examination Week | ||
20:Vacation | ||
21:Vacation | ||
22:Vacation | ||
23:Vacation | ||
24:Vacation | ||
25:Vacation | ||
26:Vacation | ||
27:Vacation | ||
28:Vacation | ||
29:Vacation | ||
30:Vacation | ||
31:Vacation | ||
32:Orientation Week | ||
33:Week 1 | ||
34:Week 2 | ||
35:Week 3 | ||
36:Week 4 | ||
37:Week 5 | ||
38:Week 6 | ||
39:Recess Week | ||
40:Week 7 | ||
41:Week 8 | ||
42:Week 9 | ||
43:Week 10 | ||
44:Week 11 | ||
45:Week 12 | ||
46:Week 13 | ||
47:Reading Week | ||
48:Examination Week | ||
49:Examination Week | ||
50:Vacation | ||
51:Vacation | ||
52:Vacation |
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<Planner> | ||
<semester> | ||
<noOfWeeks>0</noOfWeeks> | ||
<days/> | ||
</semester> | ||
</Planner> |
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 |
---|---|---|
|
@@ -3,8 +3,11 @@ | |
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javafx.util.Pair; | ||
import planmysem.common.Utils; | ||
import planmysem.data.exception.IllegalValueException; | ||
import planmysem.data.recurrence.Recurrence; | ||
import planmysem.data.semester.Semester; | ||
import planmysem.data.slot.Description; | ||
import planmysem.data.slot.Location; | ||
import planmysem.data.slot.Name; | ||
|
@@ -19,49 +22,90 @@ public class AddCommandP extends CommandP { | |
|
||
public static final String COMMAND_WORD = "add"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a slot to the Planner. " | ||
+ "Contact details can be marked private by prepending 'p' to the prefix.\n\t" | ||
+ "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n\t" | ||
+ "Example: " + COMMAND_WORD | ||
+ " John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney"; | ||
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a single or multiple slot to the Planner." | ||
+ "\n\tParameters: NAME st/START_TIME et/END_TIME|DURATION [date/DATE|DAY_OF_WEEK] " | ||
+ "[l/LOCATION] [d/DESCRIPTION] [r/recess|norecess] [r/reading|noreading] [r/normal|nonormal] [t/TAG].." | ||
+ "\n\tExample: " + COMMAND_WORD | ||
+ " CS2113T Tutorial st/0800 et/0900 date/tuesday l/COM2 r/norecess r/noreading " | ||
+ " t/tutorial t/cs2113t t/module"; | ||
|
||
public static final String MESSAGE_SUCCESS = "New slot added: %1$s"; | ||
// public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; | ||
public static final String MESSAGE_SUCCESS = "New slot(s) added: %1$s"; | ||
public static final String MESSAGE_SUCCESS_NO_CHANGE = "No slots were added."; | ||
public static final String MESSAGE_FAIL_OUT_OF_BOUNCE = "Date specified is out of bounce."; | ||
|
||
private final Slot slot; | ||
private final Pair<Slot, Recurrence> toAdd; | ||
|
||
/** | ||
* Convenience constructor using raw values. | ||
* | ||
* @throws IllegalValueException if any of the raw values are invalid | ||
*/ | ||
public AddCommandP(String name, String location, String description, String startTime, | ||
int duration, Set<String> tags) throws IllegalValueException { | ||
public AddCommandP(String date, String name, String location, String description, String startTime, | ||
String endTime, Set<String> tags, Set<String> recurrences) throws IllegalValueException { | ||
|
||
final Set<Tag> tagSet = new HashSet<>(); | ||
for (String tagName : tags) { | ||
tagSet.add(new Tag(tagName)); | ||
} | ||
|
||
// check variable date if it is a date or day | ||
int day = Utils.getDay(date); | ||
if (day != 0) { | ||
toAdd = new Pair<>(new Slot(new Name(name), new Location(location), new Description(description), | ||
Utils.parseTime(startTime), Utils.parseTime(endTime), tagSet), new Recurrence(recurrences, day)); | ||
} else { | ||
toAdd = new Pair<>(new Slot(new Name(name), new Location(location), new Description(description), | ||
Utils.parseTime(startTime), Utils.parseTime(endTime), tagSet), | ||
new Recurrence(recurrences, Utils.parseDate(date))); | ||
} | ||
} | ||
|
||
/** | ||
* Convenience constructor using raw values. | ||
* | ||
* @throws IllegalValueException if any of the raw values are invalid | ||
*/ | ||
public AddCommandP(String date, String name, String location, String description, String startTime, | ||
int duration, Set<String> tags, Set<String> recurrences) throws IllegalValueException { | ||
final Set<Tag> tagSet = new HashSet<>(); | ||
|
||
for (String tagName : tags) { | ||
tagSet.add(new Tag(tagName)); | ||
} | ||
|
||
this.slot = new Slot(new Name(name), new Location(location), new Description(description), | ||
Utils.getLocalTime(startTime), duration, tagSet); | ||
// check variable date if it is a date or day | ||
int day = Utils.getDay(date); | ||
if (day != 0) { | ||
toAdd = new Pair<>(new Slot(new Name(name), new Location(location), new Description(description), | ||
Utils.parseTime(startTime), duration, tagSet), new Recurrence(recurrences, day)); | ||
} else { | ||
toAdd = new Pair<>(new Slot(new Name(name), new Location(location), new Description(description), | ||
Utils.parseTime(startTime), duration, tagSet), new Recurrence(recurrences, Utils.parseDate(date))); | ||
} | ||
} | ||
|
||
public AddCommandP(Slot slot) { | ||
this.slot = slot; | ||
public AddCommandP(Pair<Slot, Recurrence> toAdd) { | ||
this.toAdd = toAdd; | ||
} | ||
public ReadOnlySlot getSlot() { | ||
return slot; | ||
|
||
public Pair<? extends ReadOnlySlot, Recurrence> getSlots() { | ||
return toAdd; | ||
} | ||
|
||
@Override | ||
public CommandResultP execute() { | ||
// try { | ||
planner.addSlot(slot); | ||
return new CommandResultP(String.format(MESSAGE_SUCCESS, slot)); | ||
// } catch (UniquePersonList.DuplicatePersonException dpe) { | ||
// return new CommandResult(MESSAGE_DUPLICATE_PERSON); | ||
// } | ||
try { | ||
int addCount = planner.addSlots(toAdd); | ||
|
||
if (addCount == 1) { | ||
return new CommandResultP(MESSAGE_SUCCESS_NO_CHANGE); | ||
} else { | ||
return new CommandResultP(String.format(MESSAGE_SUCCESS, toAdd)); | ||
} | ||
} catch (Semester.DayNotFoundException dnfe) { | ||
return new CommandResultP(MESSAGE_FAIL_OUT_OF_BOUNCE); | ||
} | ||
|
||
} | ||
|
||
} |
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,19 @@ | ||
package planmysem.commands; | ||
|
||
/** | ||
* Terminates the program. | ||
*/ | ||
public class ExitCommandP extends CommandP { | ||
|
||
public static final String COMMAND_WORD = "exit"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Exits the program.\n\t" | ||
+ "Example: " + COMMAND_WORD; | ||
public static final String MESSAGE_EXIT_ACKNOWEDGEMENT = "Exiting PlanMySem as requested ..."; | ||
|
||
@Override | ||
public CommandResultP execute() { | ||
return new CommandResultP(MESSAGE_EXIT_ACKNOWEDGEMENT); | ||
} | ||
|
||
} |
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
Oops, something went wrong.