-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
124 lines (113 loc) · 4.14 KB
/
Main.java
File metadata and controls
124 lines (113 loc) · 4.14 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
import cs2030.simulator.Simulation;
/**
* Pass in command line arguments into the Simulation.
*/
public class Main {
/**
* Main method to take in command line arguments and update the default
* input array based on the number of command line arguments.
* @param args command line arguments.
*/
public static void main(String[] args) {
String[] input = new String[] {"1", "1", "0", "1", "1", "1", "1", "0",
"0", "0"};
int len = args.length;
switch (len) {
case 5:
input = handle5Input(args, input);
break;
case 6:
input = handle6Input(args, input);
break;
case 8:
input = handle8Input(args, input);
break;
case 9:
input = handle9Input(args, input);
break;
case 10:
input = args;
break;
default:
break;
}
Simulation s = new Simulation(input);
s.run();
}
/**
* Update the input String array with the command line argument for: (i)
* base seed of the RandomGenerator. (ii) number of servers. (iii) number
* of customers. (iv) arrival rate. (v) service rate.
* @param args inputs used to update the input array.
* @param input the input array to be updated.
* @return updated input array for the simulation.
*/
private static String[] handle5Input(String[] args, String[] input) {
input[0] = args[0];
input[1] = args[1];
input[4] = args[2];
input[5] = args[3];
input[6] = args[4];
return input;
}
/**
* Update the input String array with the command line argument for: (i)
* base seed for RandomGenerator. (ii) number of servers. (iii) maximum
* queue length. (iv) number of customers. (v) arrival rate. (vi) service
* rate.
* @param args inputs used to update the input array.
* @param input the input array to be updated.
* @return updated input array for the simulation.
*/
private static String[] handle6Input(String[] args, String[] input) {
input[0] = args[0];
input[1] = args[1];
input[3] = args[2];
input[4] = args[3];
input[5] = args[4];
input[6] = args[5];
return input;
}
/**
* Update the input String array with the command line argument for: (i)
* base seed for RandomGenerator. (ii) number of servers. (iii) maximum
* queue length. (iv) number of customers. (v) arrival rate. (vi) service
* rate. (vii) resting rate. (viii) probability of resting.
* @param args inputs used to update the input array.
* @param input the input array to be updated.
* @return updated input array for the simulation.
*/
private static String[] handle8Input(String[] args, String[] input) {
input[0] = args[0];
input[1] = args[1];
input[3] = args[2];
input[4] = args[3];
input[5] = args[4];
input[6] = args[5];
input[7] = args[6];
input[8] = args[7];
return input;
}
/**
* Update the input String array with the command line argument for: (i)
* base seed for RandomGenerator. (ii) number of servers. (iii) number of
* self-checkout counters. (iv) maximum queue length. (v) number of
* customers. (vi) arrival rate. (vii) service rate. (viii) resting rate.
* (ix) probability of resting.
* @param args inputs used to update the input array.
* @param input the input array to be updated.
* @return updated input array for the simulation.
*/
private static String[] handle9Input(String[] args, String[] input) {
input[0] = args[0];
input[1] = args[1];
input[2] = args[2];
input[3] = args[3];
input[4] = args[4];
input[5] = args[5];
input[6] = args[6];
input[7] = args[7];
input[8] = args[8];
return input;
}
}