-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.java
More file actions
132 lines (131 loc) · 3.82 KB
/
Copy pathController.java
File metadata and controls
132 lines (131 loc) · 3.82 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
import java.util.*;
/**
* Testing class
*
* @author Khalid ALmotaery
* @version 11/9/2020
*/
public class Controller
{
static int[] nI = {1,2,3,4,5,6,7,8,9,10};
/**
* Main method where testing starts
*
* @param String[] args
* @return null
*/
public static void main(String[] args){
Controller c = new Controller();
long[] LinkedListTimes = new long[nI.length];
long[] ArrayDequeTimes = new long[nI.length];
//testing the method times with different number of iteams and random seeds:
for(int i = 0; i <nI.length; i ++ ){
LinkedListTimes[i] = c.timeOfSimulationWithLinkedLists();
}
for(int i = 0; i <nI.length; i ++ ){
ArrayDequeTimes[i]= c.timeOfSimulationWithDeque();
}
for( int i = 1; i<nI.length; i++){
System.out.println(ArrayDequeTimes[i]);
}
System.out.println("timesOfSimulationWithArrayDeque");
for( int i = 1; i<nI.length; i++){
System.out.println(LinkedListTimes[i]);
}
System.out.println("timesOfSimulationWithLinkedList");
c.netProfitAndCashers();
System.out.println("profits with different cashers (1-10)");
c.overflowWithDifferentCashers();
System.out.println("% of overFlow with different cashers(1-8)");
c.maxWaitTimeWithDifferentCashers();
System.out.println("max waiting times with different cashers(1-8)");
}
/**
* Runs the simulation
*
* @param int cashers, the number of cashiers, int dequeuOrLinkedList is either 1 or 0 to choose the data structure
* @return null
*/
public void runProgram(int cashers,int dequeuOrLinkedList){
Simulation r = new Simulation(cashers, dequeuOrLinkedList);
}
/**
* Tests for time
*
* @param
* @return null
*/
public long timeOfSimulationWithLinkedLists(){
Controller c = new Controller();
long time1 = System.currentTimeMillis();
c.runProgram(1,0);
long time2 = System.currentTimeMillis();
long time = time2-time1;
return time;
}
/**
* Tests for time
*
* @param
* @return null
*/
public long timeOfSimulationWithDeque(){
Controller c = new Controller();
long time1 = System.currentTimeMillis();
c.runProgram(1,1);
long time2 = System.currentTimeMillis();
long time = time2-time1;
return time;
}
/**
* Test for profits
*
* @param
* @return null
*/
public void netProfitAndCashers(){
Controller c = new Controller();
int[] profit= new int[20];
for( int i = 1; i<20; i++){
Simulation r = new Simulation(i, 0);
profit[i] = r.netProfit;
}
for(int i =1; i<20; i++){
System.out.println(profit[i]);
}
}
/**
* Test for overflow
*
* @param
* @return null
*/
public void overflowWithDifferentCashers(){
Controller c = new Controller();
double[] flow= new double[10];
for( int i = 1; i<10; i++){
Simulation r = new Simulation(i, 0);
flow[i] = r.percentOverFlow;
}
for(int i =1; i<10; i++){
System.out.println(flow[i]);
}
}
/**
* Test for waiting time
*
* @param
* @return null
*/
public void maxWaitTimeWithDifferentCashers(){
Controller c = new Controller();
double[] wait= new double[10];
for( int i = 1; i<10; i++){
Simulation r = new Simulation(i, 0);
wait[i] = r.avWaitTime;
}
for(int i =1; i<10; i++){
System.out.println(wait[i]);
}
}
}