Skip to content

Commit 19b44ba

Browse files
committed
Added all javadoc comments and tested them with command line java doc generation
1 parent c0c99b0 commit 19b44ba

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

code/src/Dealing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public int getCategories() {
5656

5757
/**
5858
*
59-
* @param category
59+
* @param category Category for which the number of cards is returned
6060
* @return number of cards in the specified category
6161
*/
6262
public int numberOfCards(int category) {

code/src/KripkeModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public KripkeModel(Dealing point, int players) {
2626

2727
/**
2828
* Updates the Kripke model so that all agents know what cards they have been dealt
29-
* @param point
29+
* @param point The point of the model
3030
*/
3131
private void dealCards(Dealing point) {
3232
for (int category = 0; category < point.getCategories(); category++) {
@@ -55,6 +55,7 @@ private void agentCheck(int agent) {
5555

5656
/**
5757
* Constructs a deep copy (except for sdMap) of the KripkeModel.
58+
* @param other Kripkemodel to be deep copied
5859
*/
5960
public KripkeModel(KripkeModel other) {
6061
this.agents = other.getAgents();

code/src/StateDealingMap.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ public int size() {
4242
* @param categorySizes List of sizes of card getCategories
4343
* @param players Number of players in the game
4444
* @param point Point of pointed model
45+
* @param totalCards Total number of cards in the game
4546
*/
4647
private void buildMap(int[] categorySizes, int players, Dealing point, int totalCards) {
4748
Dealing empty = new Dealing(categorySizes);
4849
//Determine possible envelope contents
4950
ArrayList<Dealing> envelopeDealings = possibleEnvelopeDealings(0, empty, categorySizes);
5051

51-
//TODO DEBUG
52-
System.out.println("nr of envelope dealings: " + envelopeDealings.size());
53-
5452
//Determine how many cards a player can maximally get
5553
int cardsLeft = totalCards - categorySizes.length;
5654
int maxHandSize = cardsLeft/players;
@@ -90,11 +88,15 @@ private ArrayList<Dealing> possibleEnvelopeDealings(int catNr, Dealing soFar, in
9088
//Return all these combinations for each card of the current category
9189
return returnDealing;
9290
}
93-
91+
9492
/**
95-
* Saves all dealings to the map for a given envelope dealing
96-
* @param envelopeDealing Dealing in which the envelope already contains its cards
93+
*
94+
* @param playerID Player that is currently being dealt to
95+
* @param soFar The dealing so far
9796
* @param players Number of players in the game
97+
* @param point Point of the model
98+
* @param maxHandSize Maximum number of cards a player
99+
* @param cardsLeft Number of cards that have not been dealt yet
98100
*/
99101
private void mapDealings(int playerID, Dealing soFar, int players, Dealing point, int maxHandSize, int cardsLeft) {
100102
//If all cards have been dealt
@@ -106,7 +108,12 @@ private void mapDealings(int playerID, Dealing soFar, int players, Dealing point
106108
}
107109

108110
//Determine the number of cards that should be dealt to the current player
109-
int cardsDealt = Math.min(maxHandSize,cardsLeft);
111+
int playersLeft = players-playerID+1;
112+
int cardsShort = (playersLeft * maxHandSize) - cardsLeft;
113+
int cardsDealt = maxHandSize;
114+
if (cardsShort == playersLeft)
115+
--cardsDealt;
116+
110117
//Otherwise, deal as many cards as should to the next player.
111118
// Save all possible ways in which this can be done in a list
112119
ArrayList<Dealing> newDealings = dealNCardsTo(playerID, soFar, cardsDealt);
@@ -120,9 +127,10 @@ private void mapDealings(int playerID, Dealing soFar, int players, Dealing point
120127

121128
/**
122129
* Wrapper function
123-
* @param playerID
124-
* @param soFar
130+
* @param playerID Player to be dealt to
131+
* @param soFar The dealing so far
125132
* @param n number of cards to be dealt
133+
* @return A list of all possible ways in which n cards are dealt to the player
126134
*/
127135
private ArrayList<Dealing> dealNCardsTo(int playerID, Dealing soFar, int n) {
128136
// This is actually a wrapper function. The real function keeps track of dealing states instead of dealings.
@@ -142,10 +150,9 @@ private ArrayList<Dealing> dealNCardsTo(int playerID, Dealing soFar, int n) {
142150

143151
/**
144152
*
145-
* @param playerID
146-
* @param soFar
147-
* @param n
148-
* @param previous Previous card that was dealt. New cards should be drawn from further in the deck so that there cannot be duplicate states.
153+
* @param playerID Player to be dealt to
154+
* @param state Current dealing state keeping track of the previous card being dealt. New cards should be drawn from further in the deck so that there cannot be duplicate states.
155+
* @param n number of cards to be dealt
149156
* @return Individual ways in which player playerID can get n cards dealt
150157
*/
151158
private ArrayList<DealingState> dealNCardsTo(int playerID, DealingState state, int n) {
@@ -166,6 +173,8 @@ private ArrayList<DealingState> dealNCardsTo(int playerID, DealingState state, i
166173

167174
/**
168175
* Saves a dealing to the map. If the dealing is the point, it is ignored, since it already has been added.
176+
* @param dealing The dealing to be saved to the map
177+
* @param point The point of the Kripke model of which the states are being constructed
169178
*/
170179
private void addToMap(Dealing dealing, Dealing point) {
171180
// We don't want a duplicate of the point in the map. It has already been added.
@@ -176,6 +185,8 @@ private void addToMap(Dealing dealing, Dealing point) {
176185
}
177186

178187
/**
188+
* @param playerID Agent that is being dealt to
189+
* @param DealingState current state of the dealing, keeping track of the previously dealt card
179190
* @return List of all possible dealings that result from soFar when player playerID gets any new card
180191
*/
181192
private ArrayList<DealingState> dealCardTo(int playerID, DealingState state) {

0 commit comments

Comments
 (0)