/
Modules.java
70 lines (55 loc) · 1.43 KB
/
Modules.java
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
/**
* Module.java
* This is a Module class
* @author Andres Breton
* @version 1.0
* Postcondition: .
*/
import java.util.Arrays;
class Modules {
enum Types { HR, ACCOUNTS, MARKETING };
// Instance variables
String module;
Types[] types;
// Default class constructor
protected Modules() {
this.types = Types.values();
};
// Class constructor
// private Modules(String module) {
// this.module = module.toUpperCase();
// }
/** CLASS METHODS **/
//
protected void init(){
String[] types = convert();
Prompt prompt = new Prompt(types);
Integer choice = prompt.askChoice();
setModule(types[choice-1]);
}
protected void setModule(String module) {
this.module = module;
}
// Get all available modules
protected Types[] getModules() {
return Types.values();
}
//
// Launch ERP module selected
protected void launch() {
System.out.println("\nLaunching " + module + "...\n");
switch(module) {
case "HR":
HR.main(); break;
// case "ACCOUNTS":
// Accounts.main(); break;
// case "MARKETING":
// Marketing.main(); break;
}
}
private String [] convert() {
String [] arr;
arr = Arrays.stream(Types.values()).map(Enum::toString).toArray(String[]::new);
return arr;
}
}