-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMancala.java
More file actions
58 lines (52 loc) · 1.51 KB
/
Mancala.java
File metadata and controls
58 lines (52 loc) · 1.51 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
package mancala;
/**
* The Mancala class represents a mancala store that holds stones for a player in the game.
*/
public class Mancala {
private int numStones; // The number of stones currently held in the store.
/**
* Constructs a Mancala object with an initial number of stones set to 0.
*/
public Mancala() {
numStones = 0;
}
/**
* Adds a specified number of stones to the store.
* @param stones the number of stones to add to the store.
*/
public void addStones(int stones) {
this.numStones += stones;
}
/**
* Increments the number of stones in the store by 1.
* This method is similar to addStone().
*/
public void increment() {
numStones++;
}
/**
* Retrieves the current number of stones in the store.
* @return the number of stones in the store.
*/
public int getNumStones() {
return numStones;
}
/**
* Sets the number of stones in the store to a specified value.
* @param numStones the new number of stones to be set in the store.
*/
public void setNumStones(int numStones) {
this.numStones = numStones;
}
/**
* @return a string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Mancala [numStones=");
builder.append(numStones);
builder.append("]");
return builder.toString();
}
}