Skip to content

Commit

Permalink
Merge pull request #19 from AY1920S1-CS2113T-F14-3/master
Browse files Browse the repository at this point in the history
Pull
  • Loading branch information
calebtay authored Oct 25, 2019
2 parents 1d2f7aa + 29d9dda commit 4397671
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 167 deletions.
61 changes: 33 additions & 28 deletions src/main/java/CustomExceptions/RoomShareException.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
import Enums.ExceptionType;

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 wrongFormat_Text = "Wrong Format Detected";
private static final String wrongPriority_Text = "You've entered wrong format of priority";
private static final String subTask_Text = "Meetings do not support Subtasks";
public static final String wrongTaskType_Text = "Only meeting or assignment tag are accepted";
public static final String emptyDescription_Text = "You haven't included the description of you task";
public static final String emptyDate_Text = "You haven't included the date of your task";
public static final String emptyTaskType_Text = "You haven't specified the type of your task: assignment or meeting";
public static final String writeError_Text = "Error in writing file, cancelling write process...";
public static final String wrongIndexFormat_Text = "The index you've enter is in the wrong format";
public static final String wrongTimeFormat_Text = "You've entered an invalid time format";
private static final String OUT_OF_BOUNDS_TEXT = "Index is out of Bounds!";
private static final String ANOMALY_TEXT = "Anomaly Detected";
private static final String EMPTY_LIST_TEXT = "List is empty";
private static final String TIME_CLASH_TEXT = "Time Clash Detected";
private static final String WRONG_FORMAT_TEXT = "Wrong Format Detected";
private static final String WRONG_PRIORITY_TEXT = "You've entered wrong format of priority";
private static final String SUB_TASK_TEXT = "Meetings do not support Subtasks";
public static final String WRONG_TASK_TYPE_TEXT = "Only meeting or assignment tag are accepted";
public static final String EMPTY_DESCRIPTION_TEXT = "You haven't included the description of you task";
public static final String EMPTY_DATE_TEXT = "You haven't included the date of your task";
public static final String EMPTY_USER_TEXT = "You haven't included the user of your task";
public static final String EMPTY_TASK_TYPE_TEXT = "You haven't specified the type of your task: assignment or meeting";
public static final String WRITE_ERROR_TEXT = "Error in writing file, cancelling write process...";
public static final String WRONG_INDEX_FORMAT_TEXT = "The index you've enter is in the wrong format";
public static final String WRONG_TIME_FORMAT_TEXT = "You've entered an invalid time format";


private String message;
Expand All @@ -28,63 +29,67 @@ public class RoomShareException extends Exception {
public RoomShareException(ExceptionType type){
switch(type) {

case emptyUser:
message = EMPTY_USER_TEXT;
break;

case emptyList:
message = emptyList_Text;
message = EMPTY_LIST_TEXT;
break;

case writeError:
message = writeError_Text;
message = WRITE_ERROR_TEXT;
break;

case wrongIndexFormat:
message = wrongIndexFormat_Text;
message = WRONG_INDEX_FORMAT_TEXT;
break;

case wrongTimeFormat:
message = wrongTimeFormat_Text;
message = WRONG_TIME_FORMAT_TEXT;
break;

case timeClash:
message = timeClash_Text;
message = TIME_CLASH_TEXT;
break;

case wrongFormat:
message = wrongFormat_Text;
message = WRONG_FORMAT_TEXT;
break;

case outOfBounds:
message = outOfBounds_Text;
message = OUT_OF_BOUNDS_TEXT;
break;

case wrongPriority:
message = wrongPriority_Text;
message = WRONG_PRIORITY_TEXT;
break;

case subTask:
message = subTask_Text;
message = SUB_TASK_TEXT;
break;

case wrongTaskType:
message = wrongTaskType_Text;
message = WRONG_TASK_TYPE_TEXT;
break;

case emptyDescription:
message = emptyDescription_Text;
message = EMPTY_DESCRIPTION_TEXT;
break;

case emptyDate:
message = emptyDate_Text;
message = EMPTY_DATE_TEXT;
break;

case emptyTaskType:
message = emptyTaskType_Text;
message = EMPTY_TASK_TYPE_TEXT;
break;

case others:
break;

default:
message = anomaly_Text;
message = 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 {
wrongTimeFormat, wrongIndexFormat, writeError, timeClash, emptyList, wrongFormat, empty, outOfBounds, wrongPriority, test, subTask, wrongTaskType, emptyDescription, emptyDate, emptyTaskType, others
wrongTimeFormat, wrongIndexFormat, writeError, timeClash, emptyList, wrongFormat, emptyUser, outOfBounds, wrongPriority, test, subTask, wrongTaskType, emptyDescription, emptyDate, emptyTaskType, others
}
2 changes: 1 addition & 1 deletion src/main/java/Enums/HelpType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Enums;

public enum HelpType {
list, bye, find, done , delete, todo, deadline, event, recur, snooze, others, priority, reorder, exit
list, bye, find, done , delete, add, recur, snooze, others, priority, reorder, exit
}
2 changes: 1 addition & 1 deletion src/main/java/Enums/SaveType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Enums;

public enum SaveType {
A, M, empty
A, L, empty
}
6 changes: 3 additions & 3 deletions src/main/java/Model_Classes/Assignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@


/**
* An object class representing types of tasks with deadlines.
* An object class representing types of tasks: assignment.
* 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.
* 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.
Expand All @@ -37,7 +37,7 @@ public void setSubTasks(String input) {
public ArrayList<String> getSubTasks() { return subTasks; }

/**
* Returns the full description including the deadline of the task.
* Returns the full description including of the assignment.
* @return A string indicating the task type, description, and when it should be done by.
*/
@Override
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/Model_Classes/FixedDuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class FixedDuration extends Meeting {

/**
* Constructor for fixed duration
* @param description Description of event
* @param at Date of event
* @param duration Duration of event
* @param description Description of meeintg
* @param at Date of meeting
* @param duration Duration of meeting
*/
public FixedDuration(String description, Date at, String duration, String unit) {
super(description, at);
Expand All @@ -20,23 +20,23 @@ public FixedDuration(String description, Date at, String duration, String unit)

/**
* Returns duration
* @return duration of event in DD/MM/YYYY format
* @return duration of meeting in DD/MM/YYYY format
*/
public String getDuration(){
return duration;
}

/**
* Return time unit of the duration of event
* @return time unit of the duration of event
* Return time unit of the duration of meeting
* @return time unit of the duration of meeting
*/
public String getUnit() {
return unit;
}

/**
* Returns string with format of date and duration
* @return string containing date and duration of the event
* @return string containing date and duration of the meeting
*/
@Override
public String toString() {
Expand Down
36 changes: 5 additions & 31 deletions src/main/java/Model_Classes/Leave.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Model_Classes;

import Enums.TimeUnit;
import java.util.Date;

/**
Expand All @@ -11,10 +10,6 @@
public class Leave extends Task {
private Date from;
private Date to;
private boolean isFixedDuration;
private int duration;
private TimeUnit timeUnit;
private boolean isShort;
private String user;


Expand All @@ -23,16 +18,6 @@ public Leave(String description, String user, Date from, Date to) {
this.user = user;
this.from = from;
this.to = to;
this.isShort = false;
}

public Leave(String description, String user, Date from, int duration, TimeUnit unit) {
super(description, from);
this.user = user;
this.from = from;
this.duration = duration;
this.timeUnit = unit;
this.isShort = true;
}

public Date checkStartDate() {
Expand All @@ -43,24 +28,13 @@ public Date checkEndDate() {
return this.to;
}

public boolean isShort() {
return isShort;
}

public String getDuration() {
return Integer.toString(duration);
}

public TimeUnit getTimeUnit() {
return timeUnit;
@Override
public String getUser() {
return this.user;
}

@Override
public String toString() {
if(isShort) {
return "[L]" + super.toString() + " " + user + " (from: " + from + " back in( " + duration + " " + timeUnit.toString() + ")";
} else {
return "[L]" + super.toString() + " " + user + " (from: " + from + " to: " + to + ")";
}
return "[L] " + super.getDescription() + " (" + user + ")" + " (From: " + from + " To: " + to + ")";
}
}
}
14 changes: 7 additions & 7 deletions src/main/java/Model_Classes/Meeting.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import java.util.Date;

/**
* An object class representing types of tasks that are events.
* Stores the description and when the event happens.
* An object class representing types of tasks: meeting.
* Stores the description and when the meeting happens.
*/
public class Meeting extends Task {
private boolean isFixedDuration;
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
* @param description Description of the event
* @param at Time the event happens
* Constructor for Meeting object
* Takes in inputs for description of the meeting and the time the meeting occurs
* @param description Description of the meeting
* @param at Time the meeting happens
*/
public Meeting(String description, Date at) {
super(description, at);
Expand All @@ -30,7 +30,7 @@ public Meeting (String description, Date date, int duration, TimeUnit unit) {
}

/**
* Returns a string that has the full description of the vent including the occurrence time
* Returns a string that has the full description of the meeting including the occurrence time
* @return A string indicating the task type, description and the occurrence of the task
*/
@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/Model_Classes/ProgressBar.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Model_Classes;

public class ProgressBar {
private String[] bar = new String[20];
private String[] bar = new String[50];
private float total;
private float done;

Expand All @@ -19,18 +19,18 @@ public ProgressBar(float total, float done) {
* Displays the progress bar
*/
public void showBar() {
for (int i=0; i<20; i++) {
for (int i=0; i<50; i++) {
bar[i] = " ";
}
float percentage =0;
if(total >= 1) {
percentage = done / total;
for (int i = 0; i < (int)(percentage*20); i++) {
for (int i = 0; i < (int)(percentage*50); i++) {
bar[i] = "=";
}
}
System.out.print("[");
for(int i=0; i<20; i++) {
for(int i=0; i<50; i++) {
System.out.print(bar[i]);
}
System.out.print("]");
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/Model_Classes/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ public boolean hasRecurring() {
public Date getDate() { return time; }

/**
* Snoozes the Event by set amount of months
* Snoozes the task by set amount of months
* @param amount number of months to snooze
*/
public void snoozeMonth(int amount) {
this.time.setMonth(this.time.getMonth() + amount);;
}

/**
* Snoozes the Event by set amount of days
* Snoozes the task by set amount of days
* @param amount number of days to snooze
*/
public void snoozeDay(int amount) {
Expand All @@ -148,7 +148,7 @@ public void snoozeDay(int amount) {


/**
* Snoozes the Event by set amount of hours
* Snoozes the task by set amount of hours
* @param amount number of hours to snooze
*/
public void snoozeHour(int amount){
Expand All @@ -157,10 +157,12 @@ public void snoozeHour(int amount){


/**
* Snoozes the Event by set amount of hours
* Snoozes the task by set amount of hours
* @param amount number of minutes to snooze
*/
public void snoozeMinute(int amount){
this.time.setMinutes(this.time.getMinutes() + amount);
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Operations;
package Model_Classes;

import CustomExceptions.RoomShareException;
import Enums.Priority;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Operations/CheckAnomaly.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Date;

/**
* This class checks if there are clashes in timings for events
* This class checks if there are clashes in timings for meetings
*/
public class CheckAnomaly {
/**
Expand Down
Loading

0 comments on commit 4397671

Please sign in to comment.