forked from Subramaniyam507/TO-DO-LIST-APP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
81 lines (79 loc) · 2.15 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.ToDo.subbu;
import java.util.*;
public class Main {
private static Scanner scan= new Scanner (System.in);
private static ToDoFunction myTodoList= new ToDoFunction();
public static void main(String[] args) {
int command = 0;
boolean exit = false;
printCommand();
while (!exit)
{
System.out.println("Enter your command/choices:");
command= scan.nextInt();
scan.nextLine();
switch (command) {
case 0:
printCommand();
break;
case 1:
myTodoList.printTodoList();
break;
case 2:
addItem();
break;
case 3:
updateItem();
break;
case 4:
removeItem();
break;
case 5:
searchItem();
break;
case 6:
exit= true;
break;
default:
System.out.println("please pick only from given commands");
}
}
}
public static void printCommand() {
System.out.println("\n Commands:"+
"\n Press 0 : To print instructions"+
"\n Press 1 : To print all list"+
"\n Press 2 : To add list in Todo"+
"\n Press 3 : To modify item from Todo"+
"\n Press 4 : To remove item from Todo"+
"\n Press 5 : To search an item from Todo"+
"\n Press 6 : To exit the application");
}
public static void addItem() {
System.out.println("Enter the item to be added in todo list");
myTodoList.addItem(scan.nextLine());
}
public static void updateItem() {
System.out.println("Enter the item number:");
int index = scan.nextInt();
scan.nextLine();
System.out.println("Enter new item to be added:");
String myNewItem = scan.nextLine();
myTodoList.updateTodo(index-1, myNewItem);
}
public static void removeItem() {
System.out.println("Enter the item number to be deleted:");
int index = scan.nextInt();
scan.nextLine();
myTodoList.removeItem(index-1);
}
public static void searchItem() {
System.out.println("Enter the item to be searched");
String searchItem=scan.nextLine();
if(myTodoList.findItem(searchItem)== null) {
System.out.println("Item not found in you TODO list");
}else {
System.out.println(searchItem + "was found in your list");
}
}
}