-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSentry.java
More file actions
72 lines (60 loc) · 1.4 KB
/
Copy pathSentry.java
File metadata and controls
72 lines (60 loc) · 1.4 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
import java.util.Random;
/**
* This class handles everything to do with one sentry in the maze, including the degree at which it is looking at
*
*/
public class Sentry {
//class variables
private int row;
private int col;
private int degree;
private int rotSpeed; //speed and direction of rotation
/**
* Constructor.
*
* @param column Column index of Sentry
* @param row Row index of Sentry
*/
public Sentry(int column, int row) {
this.row = row;
this.col = column;
Random rand = new Random();
this.rotSpeed = rand.nextInt(3)-2; // Picks a random rotation speed
if (this.rotSpeed >= 0) rotSpeed++;
this.degree = rand.nextInt(360);
}
/**
* Update the rotation of the Sentry.
*
* @return New sentry position
*/
public int updateDegree(){
this.degree = this.degree + this.rotSpeed;
if (this.degree > 359) this.degree = 0;
return this.degree;
}
/**
* Get column index of Sentry.
*
* @return Column index
*/
public int getColumn() {
return this.col;
}
/**
* Get row index of Sentry.
*
* @return Row index
*/
public int getRow() {
return this.row;
}
/**
* Get degree of Sentry rotation.
*
* @return Degree of Sentry rotation
*/
public int getDegree() {
return this.degree;
}
}