-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.txt
73 lines (69 loc) · 2.15 KB
/
Main.txt
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
package vn.viettuts;
import java.util.Scanner;
/**
* Main class
*
* @author viettuts.vn
*/
public class Main {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
String choose = null;
boolean exit = false;
StudentManager studentManager = new StudentManager();
int studentId;
showMenu();
while (true) {
choose = scanner.nextLine();
switch (choose) {
case "1":
studentManager.add();
break;
case "2":
studentId = studentManager.inputId();
studentManager.edit(studentId);
break;
case "3":
studentId = studentManager.inputId();
studentManager.delete(studentId);
break;
case "4":
studentManager.sortStudentByGPA();
break;
case "5":
studentManager.sortStudentByName();
break;
case "6":
studentManager.show();
break;
case "0":
System.out.println("exited!");
exit = true;
break;
default:
System.out.println("invalid! please choose action in below menu:");
break;
}
if (exit) {
break;
}
// show menu
showMenu();
}
}
/**
* create menu
*/
public static void showMenu() {
System.out.println("-----------menu------------");
System.out.println("1. Add student.");
System.out.println("2. Edit student by id.");
System.out.println("3. Delete student by id.");
System.out.println("4. Sort student by gpa.");
System.out.println("5. Sort student by name.");
System.out.println("6. Show student.");
System.out.println("0. exit.");
System.out.println("---------------------------");
System.out.print("Please choose: ");
}
}