-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToDoList_IM.java
More file actions
305 lines (294 loc) · 8.7 KB
/
ToDoList_IM.java
File metadata and controls
305 lines (294 loc) · 8.7 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/**
* This is a representation of a to do list.
* This is interactive, so, you can make your own.
* Made to represent Task_IM class, Priority_IM interface, and Complexity interface.
*
* @IMukhametzhanova
* @1.8
* 4/8/19
*/
import java.util.ArrayList;
import java.util.Scanner;
public class ToDoList_IM
{
public static void main(String [] args)
{
Scanner scStr = new Scanner(System.in); //For strings
Scanner scInt = new Scanner(System.in); //For integers
ArrayList<Task_IM> toDoList = new ArrayList<Task_IM>(); //The list itself
boolean done = false; //For quitting the while loop
int choice; //For the options in the main menu
int choiceChange; //For deciding what to change in the task
int check = 0; //For checking if a task exists
int oldPriority, oldComplexity;
System.out.println("Welcome to your personal To Do List!");
while (!done)
{
System.out.println("What would you like to do?\n1) Add a new task\n2) Print out my to do list\n3) Remove a task\n4) Change a task\n5) Quit");
choice = scInt.nextInt(); //Choosing in the main menu
System.out.println();
if (choice == 1){ //Add a new task
System.out.println("Please enter the name of the task");
String task = scStr.nextLine();
System.out.println("On a scale of 1 to 10, how important is his task?");
int priority = scInt.nextInt();
System.out.println("On a scale of 1 to 10, how complex is this task?");
int complexity = scInt.nextInt();
toDoList.add(new Task_IM(task, priority, complexity)); //new Task_IM object is created
System.out.println();
}else if (choice == 2){ // Print out my to do list
if (toDoList.size() > 0){ //If there are tasks
for (int i = 0; i < toDoList.size(); i++){
System.out.println(toDoList.get(i));
}
}else{ //If there are no tasks
System.out.println("You have no tasks yet");
}
System.out.println();
}else if (choice == 3){ // Remove a task
System.out.println("Which task?");
String task = scStr.nextLine();
for (int i = 0; i < toDoList.size(); i++){
if (toDoList.get(i).getType().equals(task)){
toDoList.remove(i);
check++; //Check that this task exists
System.out.println("Task removed");
}
}
if (check == 0){ //If there is no such a task
System.out.println("There is no such task");
}
check = 0; //Reset the checking value
System.out.println();
}else if (choice == 4){ //Change a task
System.out.println("Change what?\n1) Type\n2) Priority\n3) Complexity");
choiceChange = scInt.nextInt();
System.out.println("What task?");
String task = scStr.nextLine();
if (choiceChange == 1){ //Change type
System.out.println("What do you want to change it to?");
String newTask = scStr.nextLine();
for (int i = 0; i < toDoList.size(); i++){
if (toDoList.get(i).getType().equals(task)){
toDoList.get(i).setType(newTask);
check++;
System.out.println("Task changed");
}
}
}else if (choiceChange == 2){ //Change priority
System.out.println("How important is this task now?");
int newPriority = scInt.nextInt();
for (int i = 0; i < toDoList.size(); i++){
if (toDoList.get(i).getType().equals(task)){
oldPriority = toDoList.get(i).getPriority();
toDoList.get(i).setPriority(newPriority);
check++;
System.out.println("Priority changed from " + oldPriority + " to " + toDoList.get(i).getPriority());
}
}
}else if (choiceChange == 3){
System.out.println("How complex is this task now?");
int newComplexity = scInt.nextInt();
for (int i = 0; i < toDoList.size(); i++){
if (toDoList.get(i).getType().equals(task)){
oldComplexity = toDoList.get(i).getPriority();
toDoList.get(i).setComplexity(newComplexity);
check++;
System.out.println("Complexity changed from " + oldComplexity + " to " + toDoList.get(i).getComplexity());
}
}
}
System.out.println();
}else if (choice == 5){ //Quit
System.out.println("Goodbye!");
done = true;
}else{ //No correct option
System.out.println("Please enter a number from 1 to 5");
}
}
}
}
/**
* Welcome to your personal To Do List!
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 1
*
* Please enter the name of the task
* Do homework
* On a scale of 1 to 10, how important is his task?
* 9
* On a scale of 1 to 10, how complex is this task?
* 10
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 2
*
* Do homework; Priority: 9; Complexity: 10
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 1
*
* Please enter the name of the task
* Practice guitar
* On a scale of 1 to 10, how important is his task?
* 10
* On a scale of 1 to 10, how complex is this task?
* 3
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 2
*
* Do homework; Priority: 9; Complexity: 10
* Practice guitar; Priority: 10; Complexity: 3
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 4
*
* Change what?
* 1) Type
* 2) Priority
* 3) Complexity
* 1
* What task?
* Practice guitar
* What do you want to change it to?
* Practice accordeon
* Task changed
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 2
*
* Do homework; Priority: 9; Complexity: 10
* Practice accordeon; Priority: 10; Complexity: 3
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 4
*
* Change what?
* 1) Type
* 2) Priority
* 3) Complexity
* 2
* What task?
* Do homework
* How important is this task now?
* 3
* Priority changed from 9 to 3
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 2
*
* Do homework; Priority: 3; Complexity: 10
* Practice accordeon; Priority: 10; Complexity: 3
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 4
*
* Change what?
* 1) Type
* 2) Priority
* 3) Complexity
* 3
* What task?
* Practice accordeon
* How complex is this task now?
* 6
* Complexity changed from 10 to 6
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 2
*
* Do homework; Priority: 3; Complexity: 10
* Practice accordeon; Priority: 10; Complexity: 6
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 3
*
* Which task?
* Do homework
* Task removed
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 2
*
* Practice accordeon; Priority: 10; Complexity: 6
*
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 6
*
* Please enter a number from 1 to 5
* What would you like to do?
* 1) Add a new task
* 2) Print out my to do list
* 3) Remove a task
* 4) Change a task
* 5) Quit
* 5
*
* Goodbye!
*/