-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
55 lines (42 loc) · 1.44 KB
/
Main.java
File metadata and controls
55 lines (42 loc) · 1.44 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
import java.util.ArrayList;
import common.*;
import demo.*;
public class Main {
public static void main(String[] args) {
Game game = new Game_demo();
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_0100());
machines.add(new Machine_0100());
machines.add(new Machine_0100());
machines.add(new Machine_0100());
machines.add(new Machine_0100());
machines.add(new Machine_0100());
machines.add(new Machine_0100());
// change the following as needed
int numFaults = 2;
int stepSize = 4;
int sleepTime = 500;
int p=0;
// 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<100;i++) {
for(Machine machine: machines) {
Location pos = machine.getPosition();
System.out.println(machine.name() + ":" + pos.getX() + "," + pos.getY() );
}
game.startPhase();
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}