Skip to content

Commit

Permalink
Merge pull request #66 from Chongjx/JunXiang-branch-BaseCode
Browse files Browse the repository at this point in the history
Final clean up of code for v1.0
  • Loading branch information
Chongjx authored Oct 14, 2020
2 parents 8210e7b + acf45ea commit b8b56d0
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/duke/command/AddEventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AddEventCommand extends Command {
+ "[" + PREFIX_DELIMITER + PREFIX_REMIND + " [Days before (Default: 1)]" + "] "
+ "[" + PREFIX_DELIMITER + PREFIX_STOP_RECURRING + " TIMING (Format: " + DateTimeManager.DATE_FORMAT + ")]";

private static final String COMMAND_SUCCESSFUL_MESSAGE = "Added the following!";
public static final String COMMAND_SUCCESSFUL_MESSAGE = "Added the following!";
// No COMMAND_UNSUCCESSFUL_MESSAGE as we do not expect failure to occur at this stage.

private Event event;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/duke/command/DeleteEventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class DeleteEventCommand extends Command {
public static final String COMMAND_USAGE = COMMAND_WORD + ": Deletes an event. Parameters: "
+ PREFIX_DELIMITER + PREFIX_INDEX + " INDEX";

private static final String COMMAND_SUCCESSFUL_MESSAGE = "Event deleted:" + InterfaceManager.LS;
private static final String COMMAND_UNSUCCESSFUL_MESSAGE = "Event failed to delete: " + InterfaceManager.LS;
private static final String INDEX_OUT_OF_RANGE_MESSAGE = "The index you specified is out of range. "
public static final String COMMAND_SUCCESSFUL_MESSAGE = "Event deleted:" + InterfaceManager.LS;
public static final String COMMAND_UNSUCCESSFUL_MESSAGE = "Event failed to delete: " + InterfaceManager.LS;
public static final String INDEX_OUT_OF_RANGE_MESSAGE = "The index you specified is out of range. "
+ "Please specify the index that is indicated when you print the event list";

private int index;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/duke/command/DeleteNoteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class DeleteNoteCommand extends Command {
+ PREFIX_DELIMITER + PREFIX_TITLE + " TITLE or "
+ PREFIX_DELIMITER + PREFIX_INDEX + " INDEX";

private static final String COMMAND_SUCCESSFUL_MESSAGE = "Note deleted: ";
private static final String COMMAND_UNSUCCESSFUL_MESSAGE = "This note does not exist in the notebook! ";
public static final String COMMAND_SUCCESSFUL_MESSAGE = "Note deleted: ";
public static final String COMMAND_UNSUCCESSFUL_MESSAGE = "This note does not exist in the notebook! ";

private int index;
private String title = "";
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class FindCommand extends Command {

public static final String COMMAND_USAGE = COMMAND_WORD + ": Finds a note. Parameters: KEYWORDS";

private static final String COMMAND_UNSUCCESSFUL_MESSAGE = "There are no matching notes. "
public static final String COMMAND_UNSUCCESSFUL_MESSAGE = "There are no matching notes. "
+ "Please try another search query.";
private static final String COMMAND_SUCCESSFUL_MESSAGE = "Here are the matching notes in your list:";
public static final String COMMAND_SUCCESSFUL_MESSAGE = "Here are the matching notes in your list:";

private String keywords;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/duke/command/PinCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PinCommand extends Command {
+ "[" + PREFIX_DELIMITER + PREFIX_INDEX + " INDEX] "
+ "[" + PREFIX_DELIMITER + PREFIX_TITLE + " TITLE]";

private static final String COMMAND_UNSUCCESSFUL_MESSAGE = "This note does not exists in the notebook";
public static final String COMMAND_UNSUCCESSFUL_MESSAGE = "This note does not exists in the notebook";

private int index;
private String title;
Expand Down Expand Up @@ -55,7 +55,7 @@ public String execute() {
}
} else {
for (Note notes : notebook.getNotes()) {
if (notes.getTitle().equals(title)) {
if (notes.getTitle().equalsIgnoreCase(title)) {
note = notes;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/duke/command/RemindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class RemindCommand extends Command {

public static final String COMMAND_WORD = "remind-e";

public static final String COMMAND_USAGE = COMMAND_WORD + ": Set a reminder for an event. Parameters: "
+ PREFIX_DELIMITER + PREFIX_INDEX + " INDEX";
public static final String COMMAND_USAGE = COMMAND_WORD + ": Shows the reminders for today.";

/**
* Default constructor of RemindEvent. No arguments are expected as we are only looking at reminders today.
Expand Down
47 changes: 30 additions & 17 deletions src/main/java/seedu/duke/data/exception/SystemException.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package seedu.duke.data.exception;

import seedu.duke.data.timetable.Event;
import seedu.duke.command.HelpCommand;
import seedu.duke.ui.InterfaceManager;

/**
Expand All @@ -10,20 +9,46 @@
public class SystemException extends Exception {
/** Types of exception. */
public enum ExceptionType {
// Command related exception type
EXCEPTION_INVALID_COMMAND(InterfaceManager.LS + "Invalid Command. "
+ "Please try again or enter help to get a list of valid commands." + InterfaceManager.LS),

EXCEPTION_INVALID_PREFIX("Type of prefix not recognized!"),
EXCEPTION_MISSING_MESSAGE_AFTER_COMMAND("Missing information! Please provide the necessary information!"),
EXCEPTION_MISSING_DESCRIPTION("Missing description!"),

EXCEPTION_MISSING_TITLE_PREFIX("Missing title prefix!"),
EXCEPTION_MISSING_TITLE("Missing title!"),

EXCEPTION_MISSING_TIMING_PREFIX("Please include the timing prefix."),
EXCEPTION_MISSING_TIMING("This event does not have a timing specified!"),

EXCEPTION_MISSING_TAG_PREFIX("Missing tag prefix!"),
EXCEPTION_MISSING_TAG("Missing tag name!"),

EXCEPTION_MISSING_SORT("Missing sort order! Please specify how you would like to sort. "
+ "up or down."),
EXCEPTION_INVALID_SORT_TYPE("Invalid sort order command!"
+ "Only \"up\" and \"down\" are recognized as valid commands. " + InterfaceManager.LS
+ "Up for ascending and down for descending"),

EXCEPTION_MISSING_INDEX_PREFIX("Missing index prefix!"),
EXCEPTION_MISSING_INDEX("Missing index!"),

EXCEPTION_MISSING_PIN("Missing pin!"),

EXCEPTION_MISSING_KEYWORD("No search query input. Please enter a keyword for search results."),

// Note specific exception type
EXCEPTION_INVALID_END_INPUT("Input /end on a new line!"),
EXCEPTION_INVALID_INPUT_FORMAT("Format of input is not valid!"),

// Event related exception type
EXCEPTION_MISSING_RECURRING_END_TIME("Please specify until when do you want "
+ "this event to repeat."),
EXCEPTION_EARLY_REMINDER("Please limit your reminders to at most 1 week earlier."),
EXCEPTION_INVALID_TIMING_FORMAT("Your input has a wrong format for the date time input. "
+ "Please follow the yyyy-MM-dd HH:mm format with the \"-\" and \":\" in 24-Hour Clock format"),
EXCEPTION_MISSING_TIMING_PREFIX("Please include the timing prefix."),
EXCEPTION_INVALID_LIST_TIMING_FORMAT("Your input list timing query has a wrong format. "
+ "Try YYYY-MM or YYYY"),
EXCEPTION_INVALID_REMINDER_FORMAT("Your input has a wrong format for the time before reminder. "
Expand All @@ -35,23 +60,11 @@ public enum ExceptionType {
EXCEPTION_INVALID_RECURRING_TYPE("There are only the following recurring types: "
+ "daily, weekly, monthly or yearly"),
EXCEPTION_INVALID_TIME_UNIT("That time unit is not accepted!"),
EXCEPTION_MISSING_TAG_PREFIX("Missing tag prefix!"),
EXCEPTION_MISSING_TAG("Missing tag name!"),
EXCEPTION_MISSING_SORT("Missing sort order! Please specify how you would like to sort. "
+ "up or down."),
EXCEPTION_INVALID_SORT_TYPE("Invalid sort order command!"
+ "Only \"up\" and \"down\" are recognized as valid commands. "
+ InterfaceManager.LS
+ "Up for ascending and down for descending"),
EXCEPTION_MISSING_INDEX_PREFIX("Missing index prefix!"),
EXCEPTION_MISSING_INDEX("Missing index!"),
EXCEPTION_MISSING_PIN("Missing pin!"),
EXCEPTION_MISSING_KEYWORD("No search query input. Please enter a keyword for search results."),

// General exception type
EXCEPTION_INVALID_INDEX_FORMAT("Invalid index format!"),
EXCEPTION_INVALID_INDEX_VALUE("Invalid index value!"),
EXCEPTION_FILE_CREATION_ERROR("Unable to create a file!"),
EXCEPTION_INVALID_END_INPUT("Input /end on a new line!"),
EXCEPTION_INVALID_INPUT_FORMAT("Format of input is not valid!");
EXCEPTION_FILE_CREATION_ERROR("Unable to create a file!");

/** The exception message. */
private final String exceptionMessage;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/duke/data/timetable/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

/**
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/seedu/duke/data/timetable/Reminder.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ public boolean equals(Object o) {
return true;
} else if (o instanceof Reminder) {
Reminder r = ((Reminder) o);
if (r.dateToRemind.equals(dateToRemind) && r.event.getTitle().equals(event.getTitle())) {
return true;
} else {
return false;
}
return r.dateToRemind.equals(dateToRemind) && r.event.getTitle().equals(event.getTitle());
} else {
return false;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/duke/data/timetable/Timetable.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/seedu/duke/ui/InterfaceManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package seedu.duke.ui;

import seedu.duke.data.notebook.Notebook;
import seedu.duke.data.timetable.Timetable;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
Expand Down
Loading

0 comments on commit b8b56d0

Please sign in to comment.