forked from code-differently/creative-cli-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddStudentMenu.java
More file actions
87 lines (61 loc) · 3.03 KB
/
AddStudentMenu.java
File metadata and controls
87 lines (61 loc) · 3.03 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
package org.codedifferently.cbtyson.menus;
import org.codedifferently.cbtyson.data.GroupList;
import org.codedifferently.cbtyson.data.Student;
import org.codedifferently.cbtyson.helpers.InputHandler;
import java.util.UUID;
public class AddStudentMenu {
public void promptAddStudentMenu() {
System.out.println("=============================================================");
System.out.println();
System.out.println("Add Student Menu:");
System.out.println("Lets add some students!");
System.out.println();
System.out.println("=============================================================");
boolean inStudentMenu = true;
while (inStudentMenu) {
System.out.println("Enter their First Name: ");
String firstName = InputHandler.handleStringInput();
System.out.println("Enter their Last Name: ");
String lastName = InputHandler.handleStringInput();
System.out.println("Enter their Email: ");
String email = InputHandler.handleStringInput();
System.out.println("Enter their Age: ");
int age = InputHandler.handleIntegerInput();
System.out.println("Enter their GPA: ");
double gpa = InputHandler.handleDoubleInput();
// Generate a new UUID object
String studentID = UUID.randomUUID().toString();
studentID = studentID.substring(0,6);
Student student = new Student(firstName, lastName, email, studentID, age, gpa);
boolean studentAddedToGroup = false;
while(!studentAddedToGroup) {
System.out.println();
System.out.println("Which group is this new student going to?");
System.out.println("Enter the Group ID here:");
//Actually add student to group
String groupID = InputHandler.handleStringInput();
boolean hasAddedStudent = GroupList.AddStudentToGroup(groupID, student);
if(!hasAddedStudent) {
System.out.println("What you like to create a new Group to add this student to? (y/n)");
System.out.println("=============================================================");
String answerStr = InputHandler.handleYesNoInput();
if (answerStr.equals("y")) {
AddGroupMenu addGroupMenu = new AddGroupMenu();
addGroupMenu.promptGroupMenu(student);
studentAddedToGroup = true;
}
}
else {
studentAddedToGroup = true;
}
}
System.out.println();
System.out.println("Continue adding students? (y/n)");
System.out.println("=========================================");
String answerStr = InputHandler.handleYesNoInput();
if(answerStr.equals("n")) {
inStudentMenu = false;
}
}
}
}