|
1 | | - |
2 | 1 | import java.util.Scanner; |
3 | 2 | import java.util.ArrayList; |
4 | 3 |
|
@@ -54,7 +53,7 @@ public static void main(String[] args) { |
54 | 53 |
|
55 | 54 | System.out.println("Got it. I've added this task:"); |
56 | 55 | System.out.println(" " + todo); |
57 | | - System.out.println("Now you have " + tasksList.size() + " tasks in the list"); |
| 56 | + System.out.println("Now you have " + tasksList.size() + " tasks in the list."); |
58 | 57 | } catch (EmptyTodoException e) { |
59 | 58 | System.out.println(e.getMessage()); |
60 | 59 | } |
@@ -82,7 +81,7 @@ public static void main(String[] args) { |
82 | 81 |
|
83 | 82 | System.out.println("Got it. I've added this deadline:"); |
84 | 83 | System.out.println(" " + deadlineTask); |
85 | | - System.out.println("Now you have " + tasksList.size() + " tasks in the list"); |
| 84 | + System.out.println("Now you have " + tasksList.size() + " tasks in the list."); |
86 | 85 | } else { |
87 | 86 | System.out.println("Invalid input format for deadline command."); |
88 | 87 | } |
@@ -114,19 +113,30 @@ public static void main(String[] args) { |
114 | 113 | // Print confirmation message |
115 | 114 | System.out.println("Got it. I've added this task:"); |
116 | 115 | System.out.println(" " + eventTask); |
117 | | - System.out.println("Now you have " + tasksList.size() + " tasks in the list"); |
| 116 | + System.out.println("Now you have " + tasksList.size() + " tasks in the list."); |
118 | 117 | } else { |
119 | 118 | System.out.println("Invalid input format for event command."); |
120 | 119 | } |
121 | 120 | } |
| 121 | + } else if (command.startsWith("delete")) { |
| 122 | + int taskNumber = Integer.parseInt(command.substring(7)) - 1; |
| 123 | + if (taskNumber < tasksList.size()) { |
| 124 | + Tasks task = tasksList.get(taskNumber); |
| 125 | + tasksList.remove(taskNumber); |
| 126 | + |
| 127 | + System.out.println("Noted. I've removed this task: \n" + " " + task); |
| 128 | + System.out.println("Now you have " + tasksList.size() + " tasks in the list."); |
| 129 | + } |
| 130 | + |
| 131 | + |
| 132 | + |
122 | 133 | } else { |
123 | 134 | try { |
124 | 135 | throw new UnknownInputException(); |
125 | 136 | } catch (UnknownInputException e) { |
126 | 137 | System.out.println(e.getMessage()); |
127 | 138 | } |
128 | 139 | } |
129 | | - |
130 | 140 | } |
131 | 141 | } |
132 | 142 | } |
0 commit comments