-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResult.java
84 lines (82 loc) · 2.65 KB
/
Result.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* sums up wait time, average time for the ride and the number of idle cars per minute.
*
* @author Lekso Borashvili
* @version (a version number or a date)
*/
public class Result
{
private static int waitTime = 0;
private static int rideTime = 0;
private static int expectedRideTime = 0;
private static int idleCars = 0;
private static int time = 0;
/**
* adds wait time to total wait time
* @param wt wait time
*/
public static void addWaitTime(int wt)
{
waitTime += wt;
}
/**
* adds ride time to the total
* @param rt ride time
*/
public static void addRideTime(int rt)
{
rideTime += rt;
}
/**
* adds expected ride time to the total
* @ert expected ride time
*/
public static void addExpectedRideTime(int ert)
{
expectedRideTime += ert;
}
/**
* adds idle cars to the total
* @param cars number of idle cars
*/
public static void addIdleCars(int cars)
{
idleCars += cars;
}
/**
* sets the time
* @param t time
*/
public static void setTime(int t)
{
time = t;
}
/**
* prints all the averages in by calling writer class which is already set up outside of this class
* @param graphSize graph size
* @param density chance of 2 nodes being connected
* @param numberofCars number of cars
* @param customerChance chance of customer spawn
* @param numberofCustomers number of customers
*/
public static void printData(int graphSize,int density, int numberofCars, int customerChance, int numberofCustomers) throws Exception
{
String s = Integer.toString(graphSize) + ",";
s += Integer.toString(density) + ",";
s += Integer.toString(numberofCars) + ",";
s += Integer.toString(customerChance) + ",";
s += Integer.toString(numberofCustomers) + ",";
s += Integer.toString(waitTime / numberofCustomers) + ",";
s += Integer.toString(rideTime / numberofCustomers) + ",";
s += Integer.toString(expectedRideTime / numberofCustomers) + ",";
s += Integer.toString(idleCars / time) ;
waitTime = 0;
rideTime = 0;
expectedRideTime = 0;
idleCars = 0;
time = 0;
System.out.println(s);
Writer.writeCSV(s);
Writer.nextLine();
}
}