Skip to content

Commit

Permalink
Merge pull request #10 from AY1920S1-CS2113T-F14-3/master
Browse files Browse the repository at this point in the history
updated on 20/10
  • Loading branch information
tyeryan authored Oct 20, 2019
2 parents 4b0508f + 8312555 commit 09c167c
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 314 deletions.
54 changes: 29 additions & 25 deletions src/main/java/CustomExceptions/RoomShareException.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
public class RoomShareException extends Exception {
private static final String outOfBounds_Text = "Index is out of Bounds!";
private static final String anomaly_Text = "Anomaly Detected";
private static final String emptylist_Text = "List is empty";
private static final String timeclash_Text = "Time Clash Detected";
private static final String emptyList_Text = "List is empty";
private static final String timeClash_Text = "Time Clash Detected";
private static final String wrongFormat_Text = "Wrong Format Detected";
private static final String wrongPriority_Text = "Wrong Priority Detected";
private static final String subTask_Text = "Meetings do not support Subtasks";

/**
* Constructor for DukeException Exception
Expand All @@ -17,29 +18,32 @@ public class RoomShareException extends Exception {
*/
public RoomShareException(ExceptionType type){
switch(type) {
case emptylist:
System.out.println(emptylist_Text);
break;

case timeClash:
System.out.println(timeclash_Text);
break;

case wrongFormat:
System.out.println(wrongFormat_Text);
break;

case outOfBounds:
System.out.println(outOfBounds_Text);
break;

case wrongPriority:
System.out.println(wrongPriority_Text);
break;

default:
System.out.println(anomaly_Text);
break;
case emptyList:
System.out.println(emptyList_Text);
break;

case timeClash:
System.out.println(timeClash_Text);

case wrongFormat:
System.out.println(wrongFormat_Text);
break;

case outOfBounds:
System.out.println(outOfBounds_Text);
break;

case wrongPriority:
System.out.println(wrongPriority_Text);
break;

case subTask:
System.out.println(subTask_Text);
break;

default:
System.out.println(anomaly_Text);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Enums/ExceptionType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Enums;

public enum ExceptionType {
timeClash, emptylist, wrongFormat, empty, outOfBounds, wrongPriority, test
timeClash, emptyList, wrongFormat, empty, outOfBounds, wrongPriority, test, subTask
}
2 changes: 1 addition & 1 deletion src/main/java/Enums/TimeUnit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Enums;

public enum TimeUnit {
month, day, hours, minutes
month, day, hours, minutes, unDefined
}
23 changes: 17 additions & 6 deletions src/main/java/Model_Classes/Assignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@

import Enums.TimeUnit;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;



/**
* An object class representing types of tasks with deadlines.
* Stores the description and when the task should be done by.
*/
public class Assignment extends Task {
private ArrayList<String> subTasks;
/**
* Constructor for the Deadline object.
* Takes in inputs for description and date/time the tasks should be done by.
Expand All @@ -20,10 +25,20 @@ public Assignment (String description, Date by) {
super(description, by);
}

public Assignment (String description, String duration, TimeUnit unit) {
super(description, null);
/**
* Takes in a String, splits it by "," and sets each new String as a subtask of current Task
* @param input String containing subtasks separated by ","
*/
public void setSubTasks(String input) {
subTasks = new ArrayList<>(Arrays.asList(input.split(",")));
}

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

/**
* Returns the full description including the deadline of the task.
* @return A string indicating the task type, description, and when it should be done by.
Expand All @@ -32,8 +47,4 @@ public Assignment (String description, String duration, TimeUnit unit) {
public String toString() {
return "[A]" + super.toString() + " (by: " + super.getDate() + ")";
}

public Date getBy() {
return by;
}
}
5 changes: 4 additions & 1 deletion src/main/java/Model_Classes/FixedDuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
public class FixedDuration extends Meeting {
private String duration;
private String unit;
private Date at;

/**
* Constructor for fixed duration
Expand All @@ -27,6 +26,10 @@ public String getDuration(){
return duration;
}

/**
* Return time unit of the duration of event
* @return time unit of the duration of event
*/
public String getUnit() {
return unit;
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/Model_Classes/Meeting.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
public class Meeting extends Task {
private boolean isFixedDuration;
private int duration;
private TimeUnit timeUnit;
private int duration = 0;
private TimeUnit timeUnit = TimeUnit.unDefined;
/**
* Constructor for Event object
* Takes in inputs for description of the event and the time the event occurs
Expand All @@ -19,12 +19,11 @@ public class Meeting extends Task {
*/
public Meeting(String description, Date at) {
super(description, at);
//this.at = at;
this.isFixedDuration = false;
}

public Meeting (String description, String duration, TimeUnit unit) {
super(description, null);
public Meeting (String description, Date date, int duration, TimeUnit unit) {
super(description, date);
this.duration = duration;
this.timeUnit = unit;
this.isFixedDuration = true;
Expand All @@ -37,7 +36,7 @@ public Meeting (String description, String duration, TimeUnit unit) {
@Override
public String toString() {
if (isFixedDuration){
return "[M]" + super.toString() + " (in: " + duration + " " + timeUnit.toString() + ")";
return "[M]" + super.toString() + " (on: " + super.getDate() + ") (duration: " + duration + " " + timeUnit.toString() + ")";
} else {
return "[M]" + super.toString() + " (on: " + super.getDate() + ")";
}
Expand Down
32 changes: 14 additions & 18 deletions src/main/java/Model_Classes/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class Task{
private String user;
private RecurrenceScheduleType recurrenceSchedule;
private boolean hasRecurring;
private ArrayList<String> subTasks;
private Date time;

/**
Expand All @@ -31,6 +30,8 @@ public Task(String description, Date time) {
this.isDone = false;
this.priority = Priority.low;
this.time = time;
this.user = "everyone";
this.recurrenceSchedule = RecurrenceScheduleType.none;
}

/**
Expand All @@ -46,7 +47,7 @@ public String getUser() {
* @return time the task was created
*/

public void setUser(String user) {
public void setAssignee(String user) {
this.user = user;
}

Expand All @@ -58,6 +59,13 @@ public boolean getDone() {
return isDone;
}

/**
* Sets the task to be done
*/
public void setDone(boolean done) {
isDone = done;
}

/**
* Returns the status of the completion of the task.
* shows a tick if done, and a cross if not done.
Expand All @@ -79,13 +87,6 @@ public String getDescription() {
*/
public Priority getPriority() { return priority; }

/**
* Sets the task to be done
*/
public void setDone(boolean done) {
isDone = done;
}

/**
* Sets the priority of the task
* @param p priority of the task
Expand Down Expand Up @@ -115,16 +116,12 @@ public void setRecurrenceSchedule(RecurrenceScheduleType recurrenceSchedule) {
}
}

public boolean hasRecurring() {
return hasRecurring;
}

/**
* Takes in a String, splits it by "," and sets each new String as a subtask of current Task
* @param input String containing subtasks separated by ","
* Return whether the task is recurred
* @return hasRecurring: whether the task is recurred
*/
public void setSubTasks(String input) {
subTasks = (ArrayList<String>) Arrays.asList(input.split(","));
public boolean hasRecurring() {
return hasRecurring;
}

/**
Expand Down Expand Up @@ -166,5 +163,4 @@ public void snoozeHour(int amount){
public void snoozeMinute(int amount){
this.time.setMinutes(this.time.getMinutes() + amount);
}

}
18 changes: 16 additions & 2 deletions src/main/java/Operations/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ public Parser() {
}

/**
* Returns the command that the user has given Duke.
* @return command The command given by the user to Duke.
* Returns the command that the user has given RoomShare
* @return command The command given by the user to RoomShare
*/
public String getCommand() {
String command = scanner.next().toLowerCase().trim();
return command;
}

/**
* Return the line of command that the user has given Duke
* @return command The line of command given by the user to RoomShare
*/
public String getCommandLine() {
String command = scanner.nextLine().toLowerCase().trim();
return command;
Expand All @@ -48,6 +52,16 @@ public Integer getIndex() {
return index;
}

/**
* Returns the index number requested by the user for subTask.
* @return index Index the user wishes to assign subtasks to.
*/
public Integer getIndexSubtask() {
String temp = scanner.next().trim();
int index = Integer.parseInt(temp) - 1;
return index;
}

/**
* Return a single index number or a range of index number requested by users for command 'done' and 'delete'
* @return a single index or a range of index
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/Operations/RecurHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public boolean checkRecurrence() {
Assignment recurringAssignment= new Assignment(description, getNewDate(check));
recurringAssignment.setRecurrenceSchedule(type);
recurringAssignment.setPriority(check.getPriority());
recurringAssignment.setUser(check.getUser());
recurringAssignment.setAssignee(check.getUser());
taskList.replace(index, recurringAssignment);
isEdited = true;
} else {
Meeting recurringMeeting= new Meeting(description, getNewDate(check));
recurringMeeting.setRecurrenceSchedule(type);
recurringMeeting.setPriority(check.getPriority());
recurringMeeting.setUser(check.getUser());
recurringMeeting.setAssignee(check.getUser());
taskList.replace(index, recurringMeeting);
isEdited = true;
}
Expand Down
Loading

0 comments on commit 09c167c

Please sign in to comment.