File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ public class ToDoList {
1111 while (true) {
1212 System.out.println("1. add task ");
1313 System.out.println("2. view tasks");
14- System.out.println("exit");
14+ System.out.println("3. exit");
1515 System.out.println("Enter your choice: ");
1616
1717 int options = sc.nextInt();
1818 sc.nextLine();
1919
20- switch(option ){
20+ switch(options ){
2121 case 1:
2222 addtask(sc,todolist);
2323 break;
@@ -34,5 +34,21 @@ public class ToDoList {
3434 }
3535 }
3636 }
37+ private static void addtask(Scanner sc, ArrayList<String> todolist){
38+ System.out.println("enter the task ");
39+ todolist.add(sc.nextLine());
40+ System.out.println("Task Added!!\n");
41+ }
42+
43+ private static void viewtasks (ArrayList<String> todolist) {
44+ if (todolist.isEmpty()){
45+ System.out.println("the To-Do-List is Empty !!");
46+ }
47+ else
48+ {
49+ System.out.println("To-Do-List : \n"+ String.join(".\n",todolist)+".\n");
50+ }
51+ }
52+
3753
3854}
You can’t perform that action at this time.
0 commit comments