-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserInterface.java
190 lines (175 loc) · 5.15 KB
/
UserInterface.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
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
import gradebook.MyGradeBook;
import java.io.IOException;
import java.util.Scanner;
/**
* UserInterface serves as both the command line user interface as well as the
* main controller for the GradeBook program.
* Built as the final project for CS 3500 OOD Spring 2014.
* @author Kosi Gizdarski
* @author Cameron Sun
* @author Tom Hay
* @author Ryan Cebulko
* @version 2014-04-11
*/
public class UserInterface {
/* scanner used for reading user input */
private Scanner inputScanner;
/* MyGradeBook object associated with this session */
private MyGradeBook gradebook;
/**
* Default constructor that initializes the fields of the UserInterface
*/
public UserInterface() {
inputScanner = new Scanner(System.in);
gradebook = null;
}
/**
*
*/
public void initializeGradeBook() {
printHeader();
printInitialMenu();
String[] command = getLine().split(" ");
if (command[0].equals("new")) {
gradebook = MyGradeBook.initialize();
}
else if (command[0].equals("load")) {
try {
gradebook = MyGradeBook.initializeWithFile(command[1]);
} catch (IOException e) {
e.printStackTrace();
}
}
else if (command[0].equals("exit")) {
return;
}
else {
System.out.println("Unrecognized input. Please try again.");
initializeGradeBook();
}
}
/**
*
*/
public void mainMenu() {
printHeader();
printMainMenu();
int option = getNumber();
switch (option) {
case 0: gradebook.outputGradebook();
break;
case 1:
break;
case 2:
break;
case 3: informationMenu();
break;
case 4:
break;
case 5:
break;
default:
System.out.println("Unrecognized input. Please try again.");
mainMenu();
break;
}
}
public void informationMenu() {
printHeader();
printMainMenu();
int option = getNumber();
switch (option) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
default:
System.out.println("Unrecognized input. Please try again.");
informationMenu();
break;
}
}
/**
*
*/
private void printHeader() {
System.out.println("+-------------------------------------------------+");
System.out.println("|-----------------| XxXGradeXxX |-----------------|");
System.out.println("+-------------------------------------------------+");
}
/**
*
*/
private void printInitialMenu() {
System.out.println("Here are some commands to get your started:");
System.out.println("'new' - makes an empty new gradebook");
System.out.println("'load[filename]' - loads an existing gradebook");
System.out.println("'exit' - closes the program");
}
/**
*
*/
private void printMainMenu() {
System.out.println("This is the main menu.");
System.out.println("Select what you would like to do.");
System.out.println("[0] Output GradeBook");
System.out.println("[1] Add Assignment");
System.out.println("[2] Add Student");
System.out.println("[3] Retrieve information...");
System.out.println("[4] Edit Grade");
System.out.println("[5] Exit");
System.out.print("Enter your choice here --> ");
}
/**
*
*/
private void printInformationMenu() {
System.out.println("This is the information menu.");
System.out.println("It provides all sorts of useful statistics.");
System.out.println("==== ON STUDENT ====");
System.out.println("[1] Current Grade");
System.out.println("[2] Detailed Grade Report");
System.out.println("[2] Class Summary");
System.out.println("==== ON ASSIGNMENT ====");
System.out.println("[4] Average Grade");
System.out.println("[5] Maximum");
System.out.println("[6] Median");
System.out.println("[7] Minimum");
System.out.print("Enter your numerical choice here --> ");
}
// HELPER FUNCTIONS FOR I/O
/**
*
* @return
*/
private int getNumber() {
return inputScanner.nextInt();
}
/**
*
* @return
*/
private String getLine() {
return inputScanner.nextLine();
}
/**
*
* @param args
*/
public static void main(String[] args) {
UserInterface ui = new UserInterface();
ui.printHeader();
}
}