-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.java
More file actions
145 lines (126 loc) · 4.53 KB
/
Menu.java
File metadata and controls
145 lines (126 loc) · 4.53 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
145
package company_EMS;
import java.util.Scanner;
import java.util.InputMismatchException;
public class Menu {
public static void mainMenu(Company comp){
System.out.println("\033[H\033[2J");
System.out.println("Please choose an action from the following:");
System.out.println("1. Company");
System.out.println("");
System.out.println("2. Department");
System.out.println("");
System.out.println("3. Exit");
int e = prompt(3);
switch(e){
case 1:
System.out.println("choosing 1");
companyMenu(comp);
break;
case 2:
System.out.println("choosing 2");
break;
case 3:
System.out.println("Exiting program.");
return;
}
};
public static void companyMenu(Company comp){
System.out.println("\033[H\033[2J");
System.out.println("Please choose an action from the following: ");
System.out.println("1. Company Information");
System.out.println("");
System.out.println("2. change funding to a department");
System.out.println("");
System.out.println("3. Transfer a employee");
System.out.println("");
System.out.println("4. Look up an employee");
System.out.println("");
System.out.println("5. Assign new employee to a department");
System.out.println("");
System.out.println("6. Save company information to a file");
System.out.println("");
System.out.println("7. Back to main menu");
System.out.println("");
System.out.println("8. Exit");
int e = prompt(8);
switch(e){
case 1:
System.out.println("choosing 1");
comp.companyInfo();
Scanner sc1 = new Scanner(System.in);
sc1.nextLine();
//sc.close();
companyMenu(comp);
//prompt(limit)
break;
case 2:
System.out.println("choosing 2");
break;
case 3:
System.out.println("choosing 2");
break;
case 4:
System.out.println("Exiting program.");
break;
case 5:
System.out.println("choosing 2");
break;
case 6:
System.out.println("choosing 2");
break;
case 7:
mainMenu(comp);
System.out.println("Back to main menu");
return;
}
return;
}
public static int prompt(int limit){
Scanner sc = new Scanner(System.in);
System.out.print("Please choose from the list:");
int choice;
while(true){
try{
choice = sc.nextInt();
getChoice(choice, limit);
break;
}catch(MenuChoiceException e){
sc.nextLine();
System.out.println(e.getMessage());
}catch(Exception e){
sc.nextLine();
System.out.println("Please enter a number.");
}
}
//sc.close();
return choice;
}
public static deptUpdatePromp(Company comp){
Scanner sc2 = new Scanner(System.in);
List<String> parameterList= new List<>();
while(true){
System.out.print("Please enter department name: ");
try{
Department prevDept = comp.getDept(sc2.nexLint());
}catch(Exception e){
}
}
parameterList.add(sc2.nextLine());
}
System.out.print("Please enter changed amount: ");
parameterList.add(sc2.nextLine());
Department prevDept = comp.getDept(parameterList.get[0]);
System.out.println("before:");
System.out.println("Department: " + prevDept.getName() + " Budget: " + prevDept.getBudge());
System.out.println(" ");
preDept.updateBudget(parameterList.get[1]);
System.out.println("After:");
System.out.println("Department: " + prevDept.getName() + " Budget: " + prevDept.getBudge());
System.out.println("Department: " + prevDept.getName() + " Budget: " + prevDept.getBudge());
}
public static void getChoice(int input, int limit) throws MenuChoiceException{
if(input > limit || input < 1){
throw new MenuChoiceException(limit);
}
}
}