Skip to content

Commit

Permalink
Merge (#17)
Browse files Browse the repository at this point in the history
* FIx Bug in FindCommand (#97)

Fix Bug in FindCommand

* Update User Guide documentation (#98)

* Update User Guide documentation (#99)

* Planner: Initialize weekType for each Day

* Planner: Fix Codacy issue

* Planner: Update code for initialisation of semester

* Planner: Fix Codacy and checkstyle issues

* Planner: Fix build error

* Planner: Dynamic generation of semester from date

* PlannerTest: Add JUnit test for generateSemester

* Update documentation for view command

* Add view command for monthly calendar view

* Fix Codacy issue

* UserGuide: Update user guide documentation

* UserGuide: Update user guide documentation

* Update UserGuide.adoc  (#100)

* v1.1

* fix some errors and typos

* Refactor entire project, remove all traces of Addressbook

* Update developer guide for ExportCommandP (#80)

* Update documentation for view command (#81)

* Remove remaining Addressbook classes

* Refactor some classes

* fix missing files issue

* Add test cases for add function, Utils and other code enhancements

* fix codacy issues

* fix codacy issues

* Add tests for Utils

* Add diagrams

* Update Ui.png

* fix issue with Ui.png

* Update Codacy Badge link due to reinitialization.

* Enhance ordering of slots printed
  • Loading branch information
marcus-pzj authored Mar 19, 2019
1 parent 10d7515 commit f3a75ce
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 80 deletions.
39 changes: 31 additions & 8 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,45 @@ Add a slot, named "CS2113T" on the coming monday, from 0800hrs to 0900hrs with t

This section displays the current implemented features as well as features that will be implemented in the future.

[NOTE]
*For ease of communication, this document will refer to lessons/activities/events/appointments that you might add into the Planner as _slots_.*

====
*Command Format*
* Words in UPPER_CASE are the parameters to be supplied by the user. E.g. in `t/TAG`, `TAG` is a parameter which can be used as the name of the tag.
* Items in square brackets are optional. e.g in `add n/NAME [l/LOCATION]`, `LOCATION` is an optional parameter and is not required to successfully run the command.
* Items with `…` after them can be used multiple times including zero times e.g. `[t/TAG]…` can be used 0 times, or as `t/lab`, `t/lecture`, `t/tutorial` etc.
* Parameters can be in any order e.g. if the command specifies `st/START_TIME et/END_TIME d/DATE`, then both `et/09:00 st/08:00 d/2-13-2019` and `et/09:00 d/2-13-2019 st/08:00` are acceptable.
*Tagging System*
Unlike other commercial calendar/scheduling/planner software, PlanMySem makes use of a tagging system to manage slots.
Using tags to tag slots will make tasks easier for you in the future. Tasks such as viewing, deleting and editing slots will be more efficient and performed quicker.
Recommended uses for tags:
1. Tag modules. e.g. "CS2113T", "CS2101".
2. Tag type of lesson. e.g. "Lecture", "Tutorial", "Lab".
3. Tag type of activities. e.g. "Sports", "Seminar", "Talk"
4. Tag difficulty of task. e.g. "Tough", "Simple", "Trivial"
*Recursion System*
Recursion facilitate quick addition of multiple slots, similar to Microsoft Outlook's series of appointments.
In NUS, academic semesters are split into weeks of several types. Recursion allows you to add slots to these types of weeks with ease through the use of the `r/` parameter.
*Parameters*
Parameters in _PlanMySem_ are designed to be, short and easy to memorise. Once you are familarised with them, they should be intuitive to use.
The list of parameters below is useful for your reference as you jump right into grasping the system.
*Command Format*
* Words in UPPER_CASE are the parameters to be supplied by the user. E.g. in `t/TAG`, `TAG` is a parameter which can be used as the name of the tag.
* Items in square brackets are optional. e.g in `add [l/LOCATION]`, `LOCATION` is a parameter that may be omited.
* Items with `…` after them can be used multiple times including zero times e.g. `[t/TAG]…` can be used as (i.e. 0 times), `t/lab`, `t/lecture`, `t/tutorial` etc.
* Parameters can be in any order e.g. if the command specifies `st/START_TIME et/END_TIME d/DATE`, then both `et/09:00 st/08:00 d/2-13-2019` and `et/09:00 d/2-13-2019 st/08:00` is also acceptable.
[horizontal]
*Parameter*:: *Description*
`n/`:: *Name of an activity _slot_.*
`n/`:: *Name of a _slot_.*
`d/`:: *Date / Day of week.* +
Format: +
* Dates: `01-01`, `2019-01-02`
Expand All @@ -85,7 +108,7 @@ The list of parameters below is useful for your reference as you jump right into
* 24-Hour in the form of “hh:mm”. e.g. `23:00`
* 12-Hour in the form of `hh:mm+AM|PM`. e.g. `12:30 AM`
* Duration of the event in minutes. e.g. `60` represents 60 minutes
`r/`:: *Specify recurrence of an activity _slot_.* +
`r/`:: *Specify recurrence of a _slot_.* +
Format: +
* Select normal weeks: `normal`
* Select recess week: `recess`
Expand All @@ -95,7 +118,7 @@ The list of parameters below is useful for your reference as you jump right into
`l/`:: *Location.*
`des/`:: *Description.*
`t/`:: *Tag.*
`nn/`:: *New name of an activity _slot_.*
`nn/`:: *New name of a _slot_.*
`nd/`:: *New Date.*
`nst/`:: *New Start Time.*
`net/`:: *New End Time.*
Expand Down
12 changes: 8 additions & 4 deletions src/planmysem/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import planmysem.common.Utils;
import planmysem.data.exception.IllegalValueException;
Expand Down Expand Up @@ -65,7 +65,7 @@ public AddCommand(int day, String name, String location, String description, Loc
@Override
public CommandResult execute() {
Set<LocalDate> dates = recurrence.generateDates(planner.getSemester());
HashMap<LocalDate, Day> days = new HashMap<>();
Map<LocalDate, Day> days = new TreeMap<>();

for (LocalDate date : dates) {
try {
Expand All @@ -86,17 +86,21 @@ public CommandResult execute() {
/**
* Craft success message.
*/
public static String craftSuccessMessage(HashMap<LocalDate, Day> days, Slot slot) {
public static String craftSuccessMessage(Map<LocalDate, Day> days, Slot slot) {
StringBuilder sb = new StringBuilder();
sb.append("On dates:");

int count = 1;
for (Map.Entry<LocalDate, Day> day : days.entrySet()) {
sb.append("\n\t");
sb.append("\n");
sb.append(count);
sb.append(".\t");
sb.append(day.getValue().getType());
sb.append(", ");
sb.append(day.getKey().toString());
sb.append(", ");
sb.append(day.getKey().getDayOfWeek().toString());
count++;
}
sb.append("\n\n");

Expand Down
17 changes: 9 additions & 8 deletions src/planmysem/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public void setData(Planner planner, List<Pair<LocalDate, ? extends ReadOnlySlot
this.relevantSlots = slots;
}

public int getTargetIndex() {
return targetIndex;
}

public void setTargetIndex(int targetIndex) {
this.targetIndex = targetIndex;
}


/**
* Extracts the the target Day in the last shown list from the given arguments.
*
Expand All @@ -74,12 +83,4 @@ public void setData(Planner planner, List<Pair<LocalDate, ? extends ReadOnlySlot
protected Pair<LocalDate, ? extends ReadOnlySlot> getTargetSlot() throws IndexOutOfBoundsException {
return relevantSlots.get(targetIndex - DISPLAYED_INDEX_OFFSET);
}

public int getTargetIndex() {
return targetIndex;
}

public void setTargetIndex(int targetIndex) {
this.targetIndex = targetIndex;
}
}
30 changes: 7 additions & 23 deletions src/planmysem/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public CommandResult execute() {
}
}
if (selectedSlots.size() == 0) {
return new CommandResult(String.format(MESSAGE_SUCCESS_NO_CHANGE, craftSelectedMessage()));
return new CommandResult(String.format(MESSAGE_SUCCESS_NO_CHANGE,
Messages.craftSelectedMessage(tags)));
}
} else {
try {
Expand All @@ -88,11 +89,11 @@ public CommandResult execute() {

// perform deletion of slots from the planner
for (Map.Entry<LocalDateTime, ? extends ReadOnlySlot> slot: selectedSlots.entrySet()) {
planner.getSemester().getDays().get(slot.getKey().toLocalDate()).removeSlot(slot.getValue());
planner.getSemester().removeSlot(slot.getKey().toLocalDate(), slot.getValue());
}

return new CommandResult(String.format(MESSAGE_SUCCESS, selectedSlots.size(),
craftSelectedMessage(), craftSuccessMessage(selectedSlots)));
Messages.craftSelectedMessage(tags), craftSuccessMessage(selectedSlots)));
}

/**
Expand All @@ -106,12 +107,10 @@ private String craftSuccessMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlot

int count = 1;
for (Map.Entry<LocalDateTime, ReadOnlySlot> editedSlot : selectedSlots.entrySet()) {
sb.append("\tItem: ");
sb.append(count);
sb.append(": ");
sb.append("\n\t\t");
sb.append(".\t");
sb.append(editedSlot.getValue().getName().toString());
sb.append("\n\t\t");
sb.append(", ");
sb.append(editedSlot.getKey().toLocalDate().toString());
sb.append(" ");
sb.append(editedSlot.getKey().toLocalTime().toString());
Expand All @@ -120,25 +119,10 @@ private String craftSuccessMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlot
sb.append(", ");
sb.append(editedSlot.getKey().getDayOfWeek().toString());
count++;
sb.append("\n\n");
}

return sb.toString();
}

/**
* Craft selected message.
*/
private String craftSelectedMessage() {
StringBuilder sb = new StringBuilder();
sb.append("Selected Slots containing tags: \n");

for (Tag tag : tags) {
sb.append("\t");
sb.append(tag.toString());
sb.append("\n");
}

return sb.toString();
}

}
46 changes: 20 additions & 26 deletions src/planmysem/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public CommandResult execute() {
}
}
if (selectedSlots.size() == 0) {
return new CommandResult(String.format(MESSAGE_SUCCESS_NO_CHANGE, craftSelectedMessage()));
return new CommandResult(String.format(MESSAGE_SUCCESS_NO_CHANGE,
Messages.craftSelectedMessage(tags)));
}
} else {
try {
Expand All @@ -130,7 +131,7 @@ public CommandResult execute() {
}

return new CommandResult(String.format(MESSAGE_SUCCESS, selectedSlots.size(),
craftSelectedMessage(), craftSuccessMessage(selectedSlots)));
Messages.craftSelectedMessage(tags), craftSuccessMessage(selectedSlots)));
}

/**
Expand All @@ -142,19 +143,19 @@ private String craftSuccessMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlot
sb.append("Details Edited: ");

if (startTime != null) {
sb.append("\n\tStart Time: ");
sb.append("\nStart Time: ");
sb.append("\"");
sb.append(startTime.toString());
sb.append("\"");
}
if (duration != -1) {
sb.append("\n\tDuration: ");
sb.append("\nDuration: ");
sb.append("\"");
sb.append(duration);
sb.append("\"");
}
if (location != null) {
sb.append("\n\tLocation: ");
sb.append("\nLocation: ");
sb.append("\"");
if ("".equals(location)) {
sb.append("null");
Expand All @@ -164,7 +165,7 @@ private String craftSuccessMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlot
sb.append("\"");
}
if (description != null) {
sb.append("\n\tDescription: ");
sb.append("\nDescription: ");
sb.append("\"");
if ("".equals(description)) {
sb.append("null");
Expand All @@ -178,14 +179,23 @@ private String craftSuccessMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlot
sb.append("Edited Slots: ");
sb.append("\n");

sb.append(craftSelectedMessage(selectedSlots));

return sb.toString();
}

/**
* Craft success message.
*/
private String craftSelectedMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlots) {
StringBuilder sb = new StringBuilder();

int count = 1;
for (Map.Entry<LocalDateTime, ReadOnlySlot> editedSlot : selectedSlots.entrySet()) {
sb.append("\tItem: ");
sb.append(count);
sb.append(": ");
sb.append("\n\t\t");
sb.append(".\t");
sb.append(editedSlot.getValue().getName().toString());
sb.append("\n\t\t");
sb.append(", ");
sb.append(editedSlot.getKey().toLocalDate().toString());
sb.append(" ");
sb.append(editedSlot.getKey().toLocalTime().toString());
Expand All @@ -194,22 +204,6 @@ private String craftSuccessMessage(Map<LocalDateTime, ReadOnlySlot> selectedSlot
sb.append(", ");
sb.append(editedSlot.getKey().getDayOfWeek().toString());
count++;
sb.append("\n\n");
}

return sb.toString();
}

/**
* Craft selected message.
*/
private String craftSelectedMessage() {
StringBuilder sb = new StringBuilder();
sb.append("Selected Slots containing tags: \n");

for (Tag tag : tags) {
sb.append("\t");
sb.append(tag.toString());
sb.append("\n");
}

Expand Down
6 changes: 2 additions & 4 deletions src/planmysem/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.regex.Pattern;

import javafx.util.Pair;

import planmysem.data.semester.Day;
import planmysem.data.slot.ReadOnlySlot;
import planmysem.data.slot.Slot;
Expand All @@ -21,8 +20,8 @@ public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";
public static final String COMMAND_WORD_SHORT = "f";
public static final String MESSAGE_SUCCESS = "%1$s Slots listed.\n%2$s";
public static final String MESSAGE_SUCCESS_NONE = "0 Slots listed.\n";
private static final String MESSAGE_SUCCESS = "%1$s Slots listed.\n%2$s";
private static final String MESSAGE_SUCCESS_NONE = "0 Slots listed.\n";
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Finds all slots whose name "

+ "contains the specified keywords (not case-sensitive).\n\t"
Expand All @@ -46,7 +45,6 @@ public CommandResult execute() {
matchedSlots.add(slots);
date = entry.getKey();
relevantSlots.add(new Pair<>(date, slots));

}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/planmysem/common/Messages.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package planmysem.common;

import java.util.Set;

import planmysem.data.tag.Tag;

/**
* Container for user visible messages.
*/
Expand Down Expand Up @@ -27,4 +31,26 @@ public class Messages {
+ "\n\t24-Hour in the form of “hh:mm”. e.g. \"23:00\""
+ "\n\t12-Hour in the form of `hh:mm+AM|PM`. e.g. \"12:30am\""
+ "\n\tOr perhaps type a duration in minutes. e.g. \"60\" to represent 60 minutes";


/**
* Craft selected message.
*/
public static String craftSelectedMessage(Set<Tag> tags) {
StringBuilder sb = new StringBuilder();
sb.append("Selected Slots containing tags: \n");

int count = 1;
for (Tag tag : tags) {
sb.append(count);
sb.append(".\t");
sb.append(tag.toString());
sb.append("\n");
count++;
}

return sb.toString();
}


}
7 changes: 7 additions & 0 deletions src/planmysem/data/semester/Semester.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public Day addSlot(LocalDate date, Slot slot) throws DateNotFoundException {
return days.get(date);
}

/**
* Removes a Slot to the Semester.
*/
public void removeSlot(LocalDate date, ReadOnlySlot slot) {
days.get(date).removeSlot(slot);
}

/**
* Edits a Slot in the Semester.
*
Expand Down
Loading

0 comments on commit f3a75ce

Please sign in to comment.