-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructPoints.java
More file actions
34 lines (27 loc) · 1.29 KB
/
ConstructPoints.java
File metadata and controls
34 lines (27 loc) · 1.29 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
public class ConstructPoints {
private RandomAlgorithm animationAlgorithm;
private int xBound;
private int yBound;
public ConstructPoints(int xBound, int yBound, int sleepTime) throws InterruptedException {
this.xBound = xBound;
this.yBound = yBound;
animationAlgorithm = new RandomAlgorithm(xBound, yBound, sleepTime);
startRunning();
}
public void startRunning() throws InterruptedException {
while(true) {
animationAlgorithm.getTriangle().setD(new Point((int) (Math.random()*xBound), (int) (Math.random()*yBound)));
while(pointDEqualToAnotherPoint())
animationAlgorithm.getTriangle().setD(new Point((int) (Math.random()*xBound), (int) (Math.random()*yBound)));
System.out.println(animationAlgorithm.getTriangle().toString());
animationAlgorithm.move(animationAlgorithm.getTriangle().getPoints()[(int) (Math.random()*3)]);
System.out.println(animationAlgorithm.getTriangle().toString()+"\n\nNEW\n\n");
}
}
public boolean pointDEqualToAnotherPoint() {
for(int i = 0; i<3; i++)
if(animationAlgorithm.getTriangle().getD().getX() == animationAlgorithm.getTriangle().getPoints()[i].getX() && animationAlgorithm.getTriangle().getD().getY() == animationAlgorithm.getTriangle().getPoints()[i].getY())
return true;
return false;
}
}