-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
55 lines (44 loc) · 1.51 KB
/
Main.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
import java.util.ArrayList;
import common.*;
import demo.*;
public class Main {
public static void main(String[] args) {
Game game = new Game_0539();
ArrayList<Machine> machines = new ArrayList<>();
// add a bunch of different machines. For now, all demo machines
// These will be replaced by machines of different students
// Add as many as you would like, and change numFaults accordingly (but less than 1/3 of total machines)
machines.add(new Machine_0539());
machines.add(new Machine_0539());
machines.add(new Machine_0539());
machines.add(new Machine_0539());
machines.add(new Machine_0539());
machines.add(new Machine_0539());
machines.add(new Machine_0539());
// change the following as needed
int numFaults = 2;
int stepSize = 4;
int sleepTime = 2000;
// Try not to change anything beyond this
for(Machine machine: machines) {
machine.setStepSize(stepSize); // pixels to move in each step
machine.start(); // starts the machine running in its own thread
}
game.addMachines(machines, numFaults);
for(int i=0;i<2;i++) {
System.out.println();
System.out.println("phaseno"+ i);
System.out.println();
game.startPhase();
for(Machine machine: machines) {
Location pos = machine.getPosition();
System.out.println(machine.name() + ":" + pos.getX() + "," + pos.getY() );
}
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}