Skip to content

Commit

Permalink
Remove border lines from Ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuLeYao committed Feb 22, 2023
1 parent f6091ea commit 74ae1f0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 105 deletions.
58 changes: 15 additions & 43 deletions src/main/java/duke/exception/DukeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@ public class DukeException extends Exception {
*/
public static void missingTimingException(String command) throws DukeException {
if (command.startsWith("deadline") && !command.contains("/by")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The timing of a deadline cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The timing of a deadline cannot be empty.");
} else if (command.startsWith("event") && !command.contains("/from")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The start time of an event cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The start time of an event cannot be empty.");
} else if (command.startsWith("event") && !command.contains("/to")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The end time of an event cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The end time of an event cannot be empty.");
}
}

Expand All @@ -39,17 +33,11 @@ public static void missingTimingException(String command) throws DukeException {
*/
public static void missingIndexException(String command) throws DukeException {
if (command.equals("mark")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The task index to mark a task as done cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The task index to mark a task as done cannot be empty.");
} else if (command.equals("unmark")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The task index to unmark a task as not done cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The task index to unmark a task as not done cannot be empty.");
} else if (command.equals("delete")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The task index to delete a task as not done cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The task index to delete a task as not done cannot be empty.");
}
}

Expand All @@ -68,18 +56,12 @@ public static void invalidIndexException(String command, int taskSize) throws Du
String index = command.split(" ")[1];
int index1 = Integer.parseInt(index);
if (index1 <= 0) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The task index to delete or un/mark a task cannot be zero or less."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The task index to delete or un/mark a task cannot be zero or less.");
} else if (index.equals("")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The task index to delete or un/mark a task cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The task index to delete or un/mark a task cannot be empty.");
} else if (index1 > taskSize) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The task index to delete or un/mark a task cannot be more than"
+ " number of tasks."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The task index to delete or un/mark a task cannot be more than"
+ " number of tasks.");
}
}
}
Expand All @@ -93,9 +75,7 @@ public static void invalidIndexException(String command, int taskSize) throws Du
public static void invalidCommandException(String command) throws DukeException {
if (!command.startsWith("event") || !(command.startsWith("deadline")) ||
!command.startsWith("todo") || command.startsWith("mark") || !command.startsWith("unmark")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! I'm sorry, but I don't know what that means :-("
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
}
}

Expand All @@ -107,21 +87,13 @@ public static void invalidCommandException(String command) throws DukeException
*/
public static void emptyCommandException(String command) throws DukeException {
if (command.equals("todo")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The description of a todo cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The description of a todo cannot be empty.");
} else if (command.equals("deadline")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The description of a deadline cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The description of a deadline cannot be empty.");
} else if (command.equals("event")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The description of an event cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The description of an event cannot be empty.");
} else if (command.equals("find deadlines or events on")) {
throw new DukeException("\t____________________________________________________________"
+ "\n\t ☹ OOPS!!! The date of a deadline/ event cannot be empty."
+ "\n\t____________________________________________________________");
throw new DukeException("\t ☹ OOPS!!! The date of a deadline/ event cannot be empty.");
}
}
}
1 change: 1 addition & 0 deletions src/main/java/duke/main/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ String getResponse(String input) {
Parser parser = new Parser();
return parser.parse(input, ui, tasks, storage);
}

return ui.printByeMessage();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/main/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public String parse(String command, Ui ui, TaskList allTasks, Storage storage) {
return ui.printFindResults(keyword, allTasks);
} else if (command.equals("bye")){
return ui.printByeMessage();
} else {
DukeException.invalidCommandException(command);
}
} catch (DukeException d) {
return d.getMessage();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/duke/main/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String printCommandList(List<Task> allTasks) {
DateTimeFormatter.ofPattern("MMM dd yyyy HHmm a");

String output;
output = "\n\t Here are the tasks in your list:";
output = "\t Here are the tasks in your list:";
for (int i = 0; i < allTasks.size(); i++) {
int numbering = i + 1;
Task task = allTasks.get(i);
Expand Down Expand Up @@ -73,7 +73,7 @@ public String printDeadlineOrEventsOnDay(LocalDate dateTime, TaskList allTasks)
DateTimeFormatter.ofPattern("MMM dd yyyy HHmm a");

String output;
output = "\n\t Here are the tasks in your list at this day:";
output = "\t Here are the tasks in your list at this day:";
int numbering = 1;
for (int i = 0; i < allTasks.getNumberOfTask(); i++) {
Task task = allTasks.getTask(i);
Expand Down Expand Up @@ -113,7 +113,7 @@ public String printFindResults(String keyword, TaskList allTasks) {
DateTimeFormatter.ofPattern("MMM dd yyyy HHmm a");

String output;
output = "\n\t Here are the matching tasks in your list:";
output = "\t Here are the matching tasks in your list:";
int numbering = 1;
for (int i = 0; i < allTasks.getNumberOfTask(); i++) {
Task task = allTasks.getTask(i);
Expand Down Expand Up @@ -149,7 +149,7 @@ public String printFindResults(String keyword, TaskList allTasks) {
*/
public String printByeMessage() {
String output;
output = "\n\t Bye. Hope to see you again soon!";
output = "\t Bye. Hope to see you again soon!";
return output;
}

Expand Down
24 changes: 8 additions & 16 deletions src/main/java/duke/task/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ public Deadline(int taskNumber, boolean taskStatus, String task, LocalDateTime t
*/
@Override
public String markAsDone() {
return "\t____________________________________________________________"
+ "\n\t Nice! I've marked this task as done:\n"
return "\t Nice! I've marked this task as done:\n"
+ "\t " + this.taskType + "[X]" + " " + super.task
+ " (by: " + this.taskDeadline.format(dateTimeFormatter1) + ")"
+ "\n\t____________________________________________________________";
+ " (by: " + this.taskDeadline.format(dateTimeFormatter1) + ")";
}

/**
Expand All @@ -42,11 +40,9 @@ public String markAsDone() {
*/
@Override
public String unmarkAsUndone() {
return "\t____________________________________________________________"
+ "\n\t OK, I've marked this task as not done yet:\n"
return "\t OK, I've marked this task as not done yet:\n"
+ "\t " + this.taskType + "[ ]" + " " + super.task
+ " (by: " + this.taskDeadline.format(dateTimeFormatter1) + ")"
+ "\n\t____________________________________________________________";
+ " (by: " + this.taskDeadline.format(dateTimeFormatter1) + ")";
}

/**
Expand All @@ -55,12 +51,10 @@ public String unmarkAsUndone() {
* @return String response that show task is added.
*/
public String printDeadlineTask() {
return "\t____________________________________________________________"
+ "\n\t Got it. I've added this task:"
return "\t Got it. I've added this task:"
+ "\n\t [D]" + super.getTaskStatus() + " " + super.task
+ "(by: " + this.taskDeadline.format(dateTimeFormatter1) + ")"
+ "\n\t Now you have " + super.totalNumOfTasks + " tasks in the list."
+ "\n\t____________________________________________________________";
+ "\n\t Now you have " + super.totalNumOfTasks + " tasks in the list.";
}

/**
Expand All @@ -71,12 +65,10 @@ public String printDeadlineTask() {
@Override
public String printDelete(List<Task> allTasks) {
int newTotalNumOfTasks = allTasks.size() - 1;
return "\t____________________________________________________________"
+ "\n\t Noted. I've removed this task:" + "\n\t " + this.taskType
return "\t Noted. I've removed this task:" + "\n\t " + this.taskType
+ super.getTaskStatus() + " " + super.task + " (by: "
+ this.taskDeadline.format(dateTimeFormatter1) + ")"
+ "\n\t Now you have " + newTotalNumOfTasks + " tasks in the list."
+ "\n\t____________________________________________________________";
+ "\n\t Now you have " + newTotalNumOfTasks + " tasks in the list.";
}

/**
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/duke/task/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ public Event(int taskNumber, boolean taskStatus, String task,
*/
@Override
public String markAsDone() {
return "\t____________________________________________________________"
+ "\n\t Nice! I've marked this task as done:\n"
return "\t Nice! I've marked this task as done:\n"
+ "\t " + this.taskType + "[X]" + " " + super.task
+ " (from: " + this.eventStartTime.format(dateTimeFormatter1)
+ " to: "
+ this.eventEndTime.format(dateTimeFormatter1)
+ "\n\t____________________________________________________________";
+ this.eventEndTime.format(dateTimeFormatter1);
}

/**
Expand All @@ -47,13 +45,11 @@ public String markAsDone() {
*/
@Override
public String unmarkAsUndone() {
return "\t____________________________________________________________"
+ "\n\t OK, I've marked this task as not done yet:\n"
return "\t OK, I've marked this task as not done yet:\n"
+ "\t " + this.taskType + "[ ]" + " " + super.task
+ " (from: " + this.eventStartTime.format(dateTimeFormatter1)
+ " to: "
+ this.eventEndTime.format(dateTimeFormatter1)
+ "\n\t____________________________________________________________";
+ this.eventEndTime.format(dateTimeFormatter1);
}

/**
Expand All @@ -62,13 +58,11 @@ public String unmarkAsUndone() {
* @return String response that show task is added.
*/
public String printEventTask() {
return "\t____________________________________________________________"
+ "\n\t Got it. I've added this task:"
return "\t Got it. I've added this task:"
+ "\n\t [E]" + super.getTaskStatus() + " " + super.task
+ "(from: " + this.eventStartTime.format(dateTimeFormatter1)
+ " to: " + this.eventEndTime.format(dateTimeFormatter1) + ")"
+ "\n\t Now you have " + super.totalNumOfTasks + " tasks in the list."
+ "\n\t____________________________________________________________";
+ "\n\t Now you have " + super.totalNumOfTasks + " tasks in the list.";
}

/**
Expand All @@ -79,13 +73,11 @@ public String printEventTask() {
@Override
public String printDelete(List<Task> allTasks) {
int newTotalNumOfTasks = allTasks.size() - 1;
return "\t____________________________________________________________"
+ "\n\t Noted. I've removed this task:" + "\n\t " + this.taskType
return "\t Noted. I've removed this task:" + "\n\t " + this.taskType
+ super.getTaskStatus() + " " + super.task + " (from: "
+ this.eventStartTime.format(dateTimeFormatter1) + " to: "
+ this.eventEndTime.format(dateTimeFormatter1) + ")" + "\n\t Now you have "
+ newTotalNumOfTasks + " tasks in the list."
+ "\n\t____________________________________________________________";
+ newTotalNumOfTasks + " tasks in the list.";
}

/**
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/duke/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ public class Task {
* @return String response that show task is marked as done.
*/
public String markAsDone() {
return "\t____________________________________________________________"
+ "\n\t Nice! I've marked this task as done:\n"
+ "\t " + "[X]" + " " + this.task
+ "\n\t____________________________________________________________";
return "\t Nice! I've marked this task as done:\n"
+ "\t " + "[X]" + " " + this.task;
}

/**
Expand All @@ -40,10 +38,8 @@ public String markAsDone() {
* @return String response that show task is unmarked as undone.
*/
public String unmarkAsUndone() {
return "\t____________________________________________________________"
+ "\n\t OK, I've marked this task as not done yet:\n"
+ "\t " + "[ ]" + " " + this.task
+ "\n\t____________________________________________________________";
return "\t OK, I've marked this task as not done yet:\n"
+ "\t " + "[ ]" + " " + this.task;
}

/**
Expand All @@ -53,8 +49,7 @@ public String unmarkAsUndone() {
*/
public String printDelete(List<Task> allTasks) {
int allTaskSize = allTasks.size() - 1;
return "\t____________________________________________________________"
+ "\n\t Noted. I've removed this task:" + "\n\t "
return "\t Noted. I've removed this task:" + "\n\t "
+ this.getTaskStatus() + " " + this.task
+ "\n\t Now you have " + allTaskSize + " tasks in the list.";
}
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/duke/task/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public Todo(int taskNumber, boolean taskStatus, String task, int totalNumOfTasks
*/
@Override
public String markAsDone() {
return "\t____________________________________________________________"
+ "\n\t Nice! I've marked this task as done:\n"
+ "\t " + this.taskType + "[X]" + " " + this.task
+ "\n\t____________________________________________________________";
return "\t Nice! I've marked this task as done:\n"
+ "\t " + this.taskType + "[X]" + " " + this.task;
}

/**
Expand All @@ -33,10 +31,8 @@ public String markAsDone() {
*/
@Override
public String unmarkAsUndone() {
return "\t____________________________________________________________"
+ "\n\t OK, I've marked this task as not done yet:\n"
+ "\t " + this.taskType + "[ ]" + " " + this.task
+ "\n\t____________________________________________________________";
return "\t OK, I've marked this task as not done yet:\n"
+ "\t " + this.taskType + "[ ]" + " " + this.task;
}

/**
Expand All @@ -45,11 +41,9 @@ public String unmarkAsUndone() {
* @return String response that show task is added.
*/
public String printToDoTask() {
return "\t____________________________________________________________"
+ "\n\t Got it. I've added this task:"
return "\t Got it. I've added this task:"
+ "\n\t [T]" + super.getTaskStatus() + " " + super.task
+ "\n\t Now you have " + super.totalNumOfTasks + " tasks in the list."
+ "\n\t____________________________________________________________";
+ "\n\t Now you have " + super.totalNumOfTasks + " tasks in the list.";
}

/**
Expand All @@ -60,11 +54,9 @@ public String printToDoTask() {
@Override
public String printDelete(List<Task> allTasks) {
int newTotalNumOfTasks = allTasks.size() - 1;
return "\t____________________________________________________________"
+ "\n\t Noted. I've removed this task:" + "\n\t " + this.taskType
return "\t Noted. I've removed this task:" + "\n\t " + this.taskType
+ super.getTaskStatus() + " " + super.task
+ "\n\t Now you have " + newTotalNumOfTasks + " tasks in the list."
+ "\n\t____________________________________________________________";
+ "\n\t Now you have " + newTotalNumOfTasks + " tasks in the list.";
}

/**
Expand Down

0 comments on commit 74ae1f0

Please sign in to comment.