Skip to content

Commit

Permalink
Fix error from git conflict overwriting certain files
Browse files Browse the repository at this point in the history
  • Loading branch information
terrytay committed Feb 15, 2020
1 parent 8b0f198 commit d299071
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions src/main/java/duke/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,54 @@ public static void newTask(String cmd) throws DukeException {
if (cmd.isEmpty()) {
throw new DukeException("Please type something.");
}
if (!cmd.contains(" ") && cmd.length() > 0) {
if (cmd.equals(availableTasks[0]) || cmd.equals(availableTasks[1])
|| cmd.equals(availableTasks[2])) {
throw new DukeException("OOPS!!! The description of a " + cmd + " cannot be empty.");
if (cmd.substring(0, 6).equals("delete")) {
todos.remove(Integer.parseInt(cmd.substring(cmd.indexOf(" ")+1))-1);
System.out.println(" Noted. I've removed this task:");
System.out.println(" " + todos.get(getSize() - 1));
System.out.println(" Now you have " + getSize() + " tasks in the list.");
} else {
if (!cmd.contains(" ") && cmd.length() > 0) {
if (cmd.equals(availableTasks[0]) || cmd.equals(availableTasks[1])
|| cmd.equals(availableTasks[2])) {
throw new DukeException("OOPS!!! The description of a " + cmd + " cannot be empty.");
}
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
}
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
}

String taskType = cmd.substring(0, cmd.indexOf(" "));
String description;
switch (taskType) {
case "todo":
if (cmd.indexOf(" ") + 1 >= cmd.length()) {
throw new DukeException("OOPS!!! The description of a todo cannot be empty. Follow format: todo [message]");
}
description = cmd.substring(cmd.indexOf(" ")+1);
todos.add(new Todo(description));
break;
case "deadline":
if ((cmd.indexOf(" ") + 1 >= cmd.length() || cmd.contains("/by") == false) && cmd.length() > 0) {
throw new DukeException("OOPS!!! The description of a deadline cannot be empty. Follow format: dead" +
"line [message] /by [date]");
}
description = cmd.substring(cmd.indexOf(" ") + 1, cmd.indexOf("/") - 1);
String by = cmd.substring(cmd.indexOf("/") + 4);
todos.add(new Deadline(description, by));
break;
case "event":
if ((cmd.indexOf(" ") + 1 >= cmd.length() || cmd.contains("/at") == false) && cmd.length() > 0) {
throw new DukeException("OOPS!!! The description of a event cannot be empty. Follow format: event [message] /at [location]");
String taskType = cmd.substring(0, cmd.indexOf(" "));
String description;
switch (taskType) {
case "todo":
if (cmd.indexOf(" ") + 1 >= cmd.length()) {
throw new DukeException("OOPS!!! The description of a todo cannot be empty. Follow format: todo [message]");
}
description = cmd.substring(cmd.indexOf(" ") + 1);
todos.add(new Todo(description));
break;
case "deadline":
if ((cmd.indexOf(" ") + 1 >= cmd.length() || cmd.contains("/by") == false) && cmd.length() > 0) {
throw new DukeException("OOPS!!! The description of a deadline cannot be empty. Follow format: dead" +
"line [message] /by [date]");
}
description = cmd.substring(cmd.indexOf(" ") + 1, cmd.indexOf("/") - 1);
String by = cmd.substring(cmd.indexOf("/") + 4);
todos.add(new Deadline(description, by));
break;
case "event":
if ((cmd.indexOf(" ") + 1 >= cmd.length() || cmd.contains("/at") == false) && cmd.length() > 0) {
throw new DukeException("OOPS!!! The description of a event cannot be empty. Follow format: event [message] /at [location]");
}
description = cmd.substring(cmd.indexOf(" ") + 1, cmd.indexOf("/") - 1);
String at = cmd.substring(cmd.indexOf("/") + 4);
todos.add(new Event(description, at));
break;
default:
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
}
description = cmd.substring(cmd.indexOf(" ")+1, cmd.indexOf("/") - 1);
String at = cmd.substring(cmd.indexOf("/") + 4);
todos.add(new Event(description, at));
break;
default:
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
System.out.println(" Got it. I've added this task:");
System.out.println(" " + todos.get(getSize() - 1));
System.out.println(" Now you have " + getSize() + " tasks in the list.");
}
System.out.println(" Got it. I've added this task:");
System.out.println(" " + todos.get(getSize() - 1));
System.out.println(" Now you have " + getSize() + " tasks in the list.");

}

Expand Down

0 comments on commit d299071

Please sign in to comment.