Skip to content

Commit

Permalink
Merge pull request #26 from AY1920S1-CS2113T-F14-3/master
Browse files Browse the repository at this point in the history
update my code
  • Loading branch information
benitokun123 authored Nov 10, 2019
2 parents 8a072d2 + 1113fad commit b96b379
Show file tree
Hide file tree
Showing 27 changed files with 749 additions and 621 deletions.
8 changes: 4 additions & 4 deletions src/main/java/CustomExceptions/DuplicateException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ public class DuplicateException extends Exception {
private String message;

/**
* Adds the appropriate index to the Duplicate task message
* Adds the appropriate index to the Duplicate task message.
* @param index index of the task with the clash
*/
public DuplicateException(int index) {
message = DUPLICATE_TASK + "Task: " + (index+1) + "\n";
message = DUPLICATE_TASK + "Task: " + (index + 1) + "\n";
}

/**
* toString() method returning the message of the Exception
* toString() method returning the message of the Exception.
* @return the message of the Exception
*/
@Override
public String toString(){
public String toString() {
return LINE + message + LINE;
}
}
59 changes: 34 additions & 25 deletions src/main/java/CustomExceptions/RoomShareException.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,42 @@ public class RoomShareException extends Exception {
private static final String WRONG_FORMAT_TEXT = "\tWrong Format Detected\n";
private static final String WRONG_PRIORITY_TEXT = "\tYou've entered wrong format of priority\n";
private static final String SUB_TASK_TEXT = "\tOnly Assignments are supported with Subtasks\n";
public static final String WRONG_TASK_TYPE_TEXT = "\tOnly meeting, assignment, or leave tag are accepted\n";
public static final String EMPTY_DESCRIPTION_TEXT = "\tYou haven't included the description of you task\n";
public static final String EMPTY_DATE_TEXT = "\tYou haven't included the date of your task\n";
public static final String EMPTY_USER_TEXT = "\tYou haven't included the user of your task\n";
public static final String EMPTY_TASK_TYPE_TEXT = "\tYou haven't specified the type of your task: assignment, meeting, or leave\n";
public static final String WRITE_ERROR_TEXT = "\tError in writing file, cancelling write process...\n";
public static final String WRONG_INDEX_FORMAT_TEXT = "\tThe index you've enter is in the wrong format\n";
public static final String WRONG_TIME_FORMAT_TEXT = "\tYou've entered an invalid time format\n";
public static final String WRONG_SORT_TYPE_TEXT = "\tPlease enter a valid sort type: priority, alphabetical or deadline\n";
public static final String LOG_ERROR_TEXT = "\tError writing to a new log file. Please try again.\n";
public static final String NEGATIVE_AMOUNT_TEXT = "\tThe amount of time cannot be negative.\n";
public static final String EMPTY_SUB_TASK = "\tYou haven't included your list of sub-tasks\n";
public static final String DUPLICATE_SUB = "\tDuplicate subtask detected\n";
public static final String LEAVE_DONE = "\tLeave cannot be set to done\n";
public static final String INVALID_INPUT_TEXT = "\tYour input String seems to be wrong.\n"
+"\tPlease check your formatting and ensure that the use of special characters are correct!\n";
public static final String LOAD_ERROR_MESSAGE = "\terror in loading file: will be initialising empty list instead!\n";
public static final String INVALID_DATE_MESSAGE = "\tThe date you've input is before the current date!\n";
public static final String WRONG_DATE_FORMAT_TEXT = "\tYou've entered invalid date or time\n";
public static final String EMPTY_INDEX = "\tPlease enter a valid index within the range of the list! Eg. restore 1\n";
private static final String WRONG_TASK_TYPE_TEXT = "\tOnly meeting, assignment, or leave tag are accepted\n";
private static final String EMPTY_DESCRIPTION_TEXT = "\tYou haven't included the description of you task\n";
private static final String EMPTY_DATE_TEXT = "\tYou haven't included the date of your task\n";
private static final String EMPTY_USER_TEXT = "\tYou haven't included the user of your task\n";
private static final String EMPTY_TASK_TYPE_TEXT = "\tYou haven't specified the type of your task: assignment, meeting, or leave\n";
private static final String WRITE_ERROR_TEXT = "\tError in writing file, cancelling write process...\n";
private static final String WRONG_INDEX_FORMAT_TEXT = "\tThe index you've enter is in the wrong format\n";
private static final String WRONG_TIME_FORMAT_TEXT = "\tYou've entered an invalid time format\n";
private static final String WRONG_SORT_TYPE_TEXT = "\tPlease enter a valid sort type: "
+ "priority, alphabetical or deadline\n";
private static final String LOG_ERROR_TEXT = "\tError writing to a new log file. Please try again.\n";
private static final String NEGATIVE_AMOUNT_TEXT = "\tThe amount of time cannot be negative.\n";
private static final String EMPTY_SUB_TASK = "\tYou haven't included your list of sub-tasks\n";
private static final String DUPLICATE_SUB = "\tDuplicate subtask detected\n";
private static final String LEAVE_DONE = "\tLeave cannot be set to done\n";
private static final String INVALID_INPUT_TEXT = "\tYour input String seems to be wrong.\n"
+ "\tPlease check your formatting and ensure that the use of special characters are correct!\n";
private static final String LOAD_ERROR_MESSAGE = "\terror in loading file: will be initialising empty list instead!\n";
private static final String INVALID_DATE_MESSAGE = "\tThe date you've input is before the current date!\n";
private static final String WRONG_DATE_FORMAT_TEXT = "\tYou've entered invalid date or time\n";
private static final String EMPTY_INDEX = "\tPlease enter a valid index within the range of the list! Eg. restore 1\n";
private static final String INVALID_LEAVE_DATE_MESSAGE = "\tPlease check your dates for your leave!\n";
private static final String NO_SUCH_SUBTASK = "\tSubtask does not exist!\n";
private static final String ASSIGNEE_SET_TO_EVERYONE = "\tThere might have been an error when setting the assignee\n"
+ "\tIt could be an error in your entry of the assignee field\n"
+ "\tHowever, if you had intended to set the assignee to 'everyone', then ignore this message\n";

private String message;

/**
* Constructor for DukeException Exception
* Constructor for DukeException Exception.
* Takes in the exception type thrown and prints out the specific error message
* @param type type of exception detected
*/
public RoomShareException(ExceptionType type){
switch(type) {
public RoomShareException(ExceptionType type) {
switch (type) {

case emptyUser:
message = EMPTY_USER_TEXT;
Expand Down Expand Up @@ -147,18 +152,22 @@ public RoomShareException(ExceptionType type){
message = NO_SUCH_SUBTASK;
break;

case assigneeSetToEveyone:
message = ASSIGNEE_SET_TO_EVERYONE;
break;

default:
message = ANOMALY_TEXT;
break;
}
}

/**
* toString() method returning the message of the Exception
* toString() method returning the message of the Exception.
* @return the message of the Exception
*/
@Override
public String toString(){
public String toString() {
return LINE + message + LINE;
}
}
8 changes: 4 additions & 4 deletions src/main/java/CustomExceptions/TimeClashException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ public class TimeClashException extends Exception {
private String message;

/**
* TimeClashException constructor
* TimeClashException constructor.
* Adds the appropriate index to the time clash message
* @param index index of task with the clash
*/
public TimeClashException(int index) {
message = TIME_CLASH_TEXT + "Task: " + (index+1) + "\n";
message = TIME_CLASH_TEXT + "Task: " + (index + 1) + "\n";
}

/**
* toString() method returning the message of the Exception
* toString() method returning the message of the Exception.
* @return the message of the Exception
*/
@Override
public String toString(){
public String toString() {
return LINE + message + LINE;
}
}
60 changes: 28 additions & 32 deletions src/main/java/Enums/ExceptionType.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
package Enums;

public enum ExceptionType {
wrongTimeFormat,
wrongIndexFormat,
wrongSortFormat,
wrongTaskType,
wrongFormat,
wrongPriority,
wrongDateFormat,
negativeTimeAmount,

timeClash,
emptyList,
emptyUser,
outOfBounds,
emptySubTask,

leaveDone,
subTaskError,
duplicateSubtask,

emptyDescription,
emptyDate,
emptyTaskType,

logError,
writeError,
loadError,

invalidInputString,
invalidDateRange,
emptyIndex,
noSubtask, invalidDateError
}
wrongTimeFormat,
wrongIndexFormat,
wrongSortFormat,
wrongTaskType,
wrongFormat,
wrongPriority,
wrongDateFormat,
negativeTimeAmount,
emptyList,
emptyUser,
outOfBounds,
emptySubTask,
leaveDone,
subTaskError,
duplicateSubtask,
emptyDescription,
emptyDate,
emptyTaskType,
logError,
writeError,
loadError,
invalidInputString,
invalidDateRange,
emptyIndex,
noSubtask,
invalidDateError,
assigneeSetToEveyone
}
5 changes: 0 additions & 5 deletions src/main/java/Enums/HelpType.java

This file was deleted.

25 changes: 23 additions & 2 deletions src/main/java/Enums/TaskType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
package Enums;

public enum TaskType {
list, bye, find, done , delete, time, snooze, others, help, priority, reorder,
restore, add, subtask, update, sort, log, overdue, reschedule, completed, show, removeoverdue
list,
bye,
find,
done,
delete,
time,
snooze,
others,
help,
priority,
reorder,
restore,
add,
subtask,
update,
sort,
log,
overdue,
reschedule,
completed,
show,
removeoverdue,
reopen
}
24 changes: 15 additions & 9 deletions src/main/java/Model_Classes/Assignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,47 @@
* Stores the description and when the task should be done by.
*/
public class Assignment extends Task {

private ArrayList<String> subTasks = new ArrayList<String>();

/**
* Constructor for the Assignment object.
* Takes in inputs for description and date/time the tasks should be done by.
* @param description Description of the task
* @param by The time the tasks should be done by.
*/
public Assignment (String description, Date by) {
public Assignment(String description, Date by) {
super(description, by);
}

/**
* Takes in arraylist of subtasks and sets it as this assignment's subtasks
* Takes in arraylist of subtasks and sets it as this assignment's subtasks.
* @param addList array list containing subtasks
*/
public void addSubTasks(ArrayList<String> addList) {
for(String output : addList) {
for (String output : addList) {
subTasks.add(output);
}
}

/**
* Takes in a String, splits it by "," and sets each new String as a subtask of current Task
* Takes in a String, splits it by "," and sets each new String as a subtask of current Task.
* @param subTasks string containing subtasks
*/
public void addSubTasks(String subTasks) { this.subTasks = new ArrayList<>(Arrays.asList(subTasks.trim().split(","))); }
public void addSubTasks(String subTasks) {
this.subTasks = new ArrayList<>(Arrays.asList(subTasks.trim().split(",")));
}

/**
* Returns the ArrayList containing the Assignment's subtasks
* @return ArrayList<String> subtasks.
* Returns the ArrayList containing the Assignment's subtasks.
* @return ArrayList of subtasks as Strings
*/
public ArrayList<String> getSubTasks() { return subTasks; }
public ArrayList<String> getSubTasks() {
return subTasks;
}

/**
* Removes completed Subtask
* Removes completed Subtask.
* @param index index of completed subtask
* @throws RoomShareException when there is no subtask at that index
*/
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/Model_Classes/Leave.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Leave extends Task {
private String user;

/**
* constructor for the leave class
* constructor for the leave class.
* @param description description of the leave
* @param user the person who is taking leave
* @param from the start date and time of the leave
Expand All @@ -27,39 +27,39 @@ public Leave(String description, String user, Date from, Date to) {
}

/**
* gets the start date of the leave
* gets the start date of the leave.
* @return the start date and time of the leave
*/
public Date getStartDate() {
return this.from;
}

/**
* sets the start date of the leave
* sets the start date of the leave.
* @param date the start date and time of the leave
*/
public void setStartDate(Date date) {
this.from = date;
}

/**
* gets the end date of the leave
* gets the end date of the leave.
* @return end date and time of the leave
*/
public Date getEndDate() {
return this.to;
}

/**
* sets the end date of the leave
* sets the end date of the leave.
* @param date the end date and time of the leave
*/
public void setEndDate(Date date) {
this.to = date;
}

/**
* gets the user who is being assigned to the leave
* gets the user who is being assigned to the leave.
* @return user who is assigned the leave
*/
@Override
Expand All @@ -68,11 +68,19 @@ public String getAssignee() {
}

/**
* returns the information of the leave being taken
* returns the information of the leave being taken.
* @return String with the information of the leave.
*/
@Override
public String toString() {
return "[L] " + super.getDescription() + " (" + user + ")" + " (From: " + from + " To: " + to + ")";
}

/**
* setter for user.
* @param user name of user for the leave
*/
public void setUser(String user) {
this.user = user;
}
}
Loading

0 comments on commit b96b379

Please sign in to comment.