@@ -41,34 +41,6 @@ public static void main(String[] args) {
4141 userInput = userScan .nextLine ();
4242 }
4343
44- //Add delete keyword and function
45- else if (Check .isDelete (userInput )){
46- //get the task number
47- int taskNumber = Integer .parseInt (userInput .substring (7 ));
48- //if the task number is greater than the task count throw an exception
49- if (taskNumber >taskCount ){
50- throw new IllegalArgumentException ("The task number is greater than the number of tasks." );
51- }
52- //if the task number is less than 1 throw an exception
53- if (taskNumber <1 ){
54- throw new IllegalArgumentException ("The task number is less than 1." );
55- }
56- //if there is no task at the task number throw an exception
57- if (tasks .get (taskNumber -1 )==null ){
58- throw new IllegalArgumentException ("There is no task at the task number." );
59- }
60- //delete the task
61- tasks .remove (taskNumber -1 );
62- //decrement the task count
63- taskCount --;
64- //print out the task that was deleted
65- System .out .println ("Noted. I've removed this task:" );
66- System .out .println (tasks .get (taskNumber -1 ));
67- System .out .println ("Now you have " + taskCount + " tasks in the list." );
68- //Get user input again
69- userInput = userScan .nextLine ();
70- }
71-
7244 //Add delete keyword and function
7345 else if (Check .isDelete (userInput )){
7446 //get the task number
@@ -87,12 +59,10 @@ else if(Check.isDelete(userInput)){
8759 }
8860 //delete the task
8961 tasks .remove (taskNumber -1 );
90- //decrement the task count
91- taskCount --;
9262 //print out the task that was deleted
9363 System .out .println ("Noted. I've removed this task:" );
9464 System .out .println (tasks .get (taskNumber -1 ));
95- System .out .println ("Now you have " + taskCount + " tasks in the list." );
65+ System .out .println ("Now you have " + tasks . size () + " tasks in the list." );
9666 //Get user input again
9767 userInput = userScan .nextLine ();
9868 }
0 commit comments