forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPeg.java
More file actions
51 lines (41 loc) · 684 Bytes
/
Peg.java
File metadata and controls
51 lines (41 loc) · 684 Bytes
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
public class Peg
{
private int position;
private int score;
public Peg()
{
position = 0;
}
public int getPosition()
{
return position;
}
public void setPosition(int position)
{
this.position = position;
}
public int getNextPosition()
{
return position + 1;
}
public void positionUp()
{
position++;
}
public void resetPosition()
{
position = 0;
}
public void positionDown()
{
position--;
}
public void scoreUp(int score)
{
this.score+= score;
}
public int getScore()
{
return score;
}
}