-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchoolMenuGen.java
More file actions
144 lines (96 loc) · 4 KB
/
SchoolMenuGen.java
File metadata and controls
144 lines (96 loc) · 4 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
/*
This menu design is not ideal because the try-catch blocks and the menus themselves are
copy-paste replications of the first menu... I have an interface for a menu. I'll make
this a lot better tomorrow (11/25).
-- Frank
*/
import java.util.InputMismatchException;
import java.util.Scanner;
public class SchoolMenuGen implements Menu {
public void showMainMenu() {
// main menu
while (true) {
System.out.println();
System.out.println("LOST IN ERWIN");
System.out.println("--------------");
System.out.println("1) Student Menu\n" +
"2) Faculty Menu\n" +
"3) Reporting Menu\n" +
"4) Administrative Menu\n" +
"5) EXIT\n");
Scanner option = new Scanner(System.in);
try {
byte opt = option.nextByte();
switch (opt) {
case 1:
showStudentMenu();
break;
case 2: //showFacultyMenu();
break;
case 3: //showReportMenu();
break;
case 4: //showAdminMenu();
break;
case 5:
System.exit(0);
break;
default:
System.out.println("error: a menu selection specified is" +
" out of bounds. Select 1-5.\n\n");
}
} catch (InputMismatchException ex) {
// clear for the next input attempt.
option.nextLine();
System.out.println("You did not choose a proper number between 1 and 5. Please" +
" try again.");
}
}
}
private void showStudentMenu() {
/* Student Menu while loop
* reminder! a new while loop is required for
* each sub-menu. Is there a better method? */
while (true) {
System.out.println("Student Menu");
System.out.println("\t------------");
System.out.println("\t1)New Student\n" +
"\t2)Courses Needed\n" +
"\t3)Preferred Schedule\n" +
"\t4)Term Schedule\n" +
"\t5)Statistics\n" +
"\t6)RETURN to Main Menu");
Scanner option = new Scanner(System.in);
try {
byte byopt = option.nextByte();
switch (byopt) {
case 1:
System.out.println("Creating new student...\n");
break;
case 2:
System.out.println("Ask DB for courses needed.\n");
break;
case 3:
System.out.println("Ask student for preferred course schedule.\n");
break;
case 4:
System.out.println("Get term schedule for student.\n");
break;
case 5:
System.out.println("Get student stats.\n");
break;
case 6:
System.out.println("Going up to main menu.\n");
return;
default:
System.out.println("error: a menu selection specified is" +
" out of bounds. Select 1-6.\n\n");
} // end switch
} catch (InputMismatchException ex) {
// clear for the next input attempt.
option.nextLine();
System.out.println("You did not choose a proper number between 1 and 6. Please" +
" try again.");
}
} // end while
}
}