-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
61 lines (56 loc) · 2.31 KB
/
Main.java
File metadata and controls
61 lines (56 loc) · 2.31 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
package Excercise_Dat4;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void menu() {
System.out.println("---Please choose ---");
System.out.println("1. Insert Information");
System.out.println("2. Update Information");
System.out.println("3. Find by Id");
System.out.println("4. Print out all");
System.out.println("0. Quit...");
System.out.print(">>> Selection: ");
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Manage manage = new Manage();
while (true){
menu();
int choiceNumber = scanner.nextInt();
switch (choiceNumber){
case 1:
Information information = new Information();
information.askData();
manage.addStaff(information);
System.out.println(information.toString());
System.out.println("Enter to continue...");
scanner.nextLine();
break;
case 2:
Information information1 = new Information();
System.out.println("Enter id");
int idUpdate = new Scanner(System.in).nextInt();
if (manage.searchInformation(idUpdate).size()!=0){
information1.setStaffId(idUpdate);
System.out.println("Enter name");
String name = new Scanner(System.in).nextLine();
information1.setName(name);
System.out.println("Enter gender");
String gender = new Scanner(System.in).nextLine();
information1.setGender(gender);
manage.update(information1);
}
case 3:
System.out.print("Enter id to search: ");
int id = new Scanner(System.in).nextInt();
manage.searchInformation(id).forEach(officer -> {
System.out.println(officer.toString());
});
break;
case 4:
manage.showList();
break;
}
}
}
}