-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPinsetterEvent.java
91 lines (78 loc) · 1.87 KB
/
PinsetterEvent.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
85
86
87
88
89
90
/* $Id$
*
* Revisions:
* $Log: PinsetterEvent.java,v $
* Revision 1.2 2003/01/26 22:34:44 ???
* Total rewrite of lane and pinsetter for R2's observer model
* Added Lane/Pinsetter Observer
* Rewrite of scoring algorythm in lane
*
* Revision 1.1 2003/01/19 21:04:24 ???
* created pinsetterevent and pinsetterobserver
*
*/
public class PinsetterEvent {
private boolean[] pinsStillStanding;
private boolean foulCommited;
private int throwNumber;
private int pinsDownThisThrow;
/** PinsetterEvent()
*
* creates a new pinsetter event
*
* @pre none
* @post the object has been initialized
*/
public PinsetterEvent(boolean[] ps, boolean foul, int tn, int pinsDownThisThrow) {
pinsStillStanding = new boolean[10];
for (int i=0; i <= 9; i++) {
pinsStillStanding[i] = ps[i];
}
foulCommited = foul;
throwNumber = tn;
this.pinsDownThisThrow = pinsDownThisThrow;
}
/** pinKnockedDown()
*
* check if a pin has been knocked down
*
* @return true if pin [i] has been knocked down
*/
public boolean pinKnockedDown(int i) {
return !pinsStillStanding[i];
}
/** pinsDownOnThisThrow()
*
* @return the number of pins knocked down assosicated with this event
*/
public int pinsDownOnThisThrow() {
return pinsDownThisThrow;
}
/** totalPinsDown()
*
* @return the total number of pins down for pinsetter that generated the event
*/
public int totalPinsDown() {
int count = 0;
for (int i=0; i <= 9; i++) {
if (pinKnockedDown(i)) {
count++;
}
}
return count;
}
/** isFoulCommited()
*
* @return true if a foul was commited on the lane, false otherwise
*/
public boolean isFoulCommited() {
return foulCommited;
}
/** getThrowNumber()
*
* @return current number of throws taken on this lane after last reset
*/
public int getThrowNumber() {
return throwNumber;
}
};