-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPit.java
111 lines (100 loc) · 2.06 KB
/
Pit.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* Fall 2022 CS151 Team Project
* Simple Mancala Board
* Instructor: Dr. Suneuy Kim
*
* @author Sean Nian, Abdugafur Dalerzoda, Xianqiao Zhang, Aarushi Gautam
* @version 1.0 12/1/2022
*/
import java.util.*;
/**
* The Pit class contains an ArrayList of stones, the player who owns the pit, the number of the pit, and which correlation the pit has to another pit.
*/
public class Pit
{
private ArrayList<Stone> stones;
private Player player;
private int pitNumber;
private Pit correlation;
/**
* Creates a pit with a number of stones and the pit number
* @param numberOfStones - the number of stones in the pit
* @param pitNumber - the number of the pit
*/
public Pit(int numberOfStones, int pitNumber)
{
stones = new ArrayList<Stone>();
this.pitNumber = pitNumber;
for(int i = 0; i < numberOfStones; i++)
{
stones.add(new Stone());
}
}
/**
* Returns how many stones are in the pit
* @return - the number of stones in the pit
*/
public int getSize()
{
return stones.size();
}
/**
* Returns the pit number
* @return - pit number
*/
public int getPitNumber()
{
return pitNumber;
}
/**
* Empties the pit
*/
public void emptyPit()
{
stones.clear();
}
/**
* Adds a certain amount of stones to the pit
* @param number - number of stones to add
*/
public void addStones(int number)
{
for(int i = 0; i < number; i++)
{
stones.add(new Stone());
}
}
/**
* Sets the correlation of the pits
* @param pit - the pit that needs correlation to be added
*/
public void setCorrelation(Pit pit)
{
this.correlation = pit;
pit.correlation = this;
}
/**
* Returns the correlation of the pit
* @return - the correlation of the pit
*/
public Pit getCorrelation()
{
return correlation;
}
/**
* Set's the player who owns the pit
* @param player - the player who owns the pit
*/
public void setPlayer(Player player)
{
this.player = player;
}
/**
* Returns the player who owns the pit
* @return - player who owns the pit
*/
public Player getPlayer()
{
return player;
}
}