-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinalProject.java
More file actions
102 lines (80 loc) · 2.65 KB
/
FinalProject.java
File metadata and controls
102 lines (80 loc) · 2.65 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
package com.robertnickle.finalProject;
import java.util.ArrayList;
import java.util.Scanner;
//I could not Figure out how to do the stretch goal for the final goal, maybe you could email what i was suppose to do there for that.i searched online a lot but no luck.
// Thank you for the extension Darrin i appreciate it.
public class FinalProject {
static ArrayList<Task> tasks;
static Scanner sc;
private static Object completeId;
public static void main(String[] args) {
tasks = new ArrayList<Task>();
sc = new Scanner(System.in);
tasks.add(new Task("brush your teeth"));
tasks.add(new Task("do your homework"));
tasks.add(new Task("do your laundry"));
tasks.add(new Task("comb your hair"));
tasks.add(new Task("Buy some milk"));
tasks.add(new Task("Buy some candy"));
boolean running = true;
do {
displayMenu();
int menuChoice = readChoice();
switch(menuChoice) {
case 1:
System.out.println("What task do you want to add:");
String taskName = sc.nextLine();
addTask(taskName);
break;
case 2:
listTasks();
System.out.println("Item needs to Remove:");
int removeId = readChoice();
removeTask(removeId);
break;
case 3:
System.out.println("Item is finished:");
int completeId = readChoice();
completeTask(completeId);
break;
case 4:
listTasks();
break;
case 0:
running = false;
break;
default:
System.out.println("Bad menu Choice");
}
}while(running);
}
public static void displayMenu() {
System.out.println("$$Task Manager$$");
System.out.println("1: Add a task");
System.out.println("2: Remove a task");
System.out.println("3: Mark a task as complete");
System.out.println("4: list the tasks");
System.out.println("0: quit task");
System.out.println("What would you like to do: ");
}
public static int readChoice() {
int result = sc.nextInt();
sc.nextLine();
return result;
}
public static void listTasks() {
System.out.println("--Tasks--");
for(int i = 0;i < tasks.size(); i++) {
System.out.println(i+1 + "" + tasks.get(i).toString());
}
}
private static void completeTask(int id) {
tasks.get(id-1).setComplete(true);
}
public static void removeTask(int id) {
tasks.remove(id-1);
}
public static void addTask(String name) {
tasks.add(new Task(name));
}
}