Function header descriptions

Ready for JavaDoc
This commit is contained in:
2015-04-27 14:38:27 +02:00
parent e285e25a34
commit 0b1b724cd2
2 changed files with 50 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
/*
/**
* PokerGame.java
*
* Course in Software Craftsmenship @ Högskolan Väst
@@ -11,6 +11,12 @@ package session3;
import java.util.Arrays;
/**
* Gives you a score with a hand of poker
*
* @author crille
*
*/
public class PokerGame {
public int getScore(String hand) {
int score = 0;
@@ -30,6 +36,13 @@ public class PokerGame {
return score;
}
/**
* Finds a pair by looking if two cards next to each other has the same
* value
*
* @param hand
* @return true if there is a pair, otherwise false
*/
private boolean findPair(String hand) {
char[] values = getValues(hand);
@@ -41,6 +54,13 @@ public class PokerGame {
return false;
}
/**
* Finds a pair by looking if three cards next to each other has the same
* value
*
* @param hand
* @return true if there is a Three of a kind, otherwise false
*/
private boolean findThreeOfAKind(String hand) {
char[] values = getValues(hand);
@@ -52,6 +72,13 @@ public class PokerGame {
return false;
}
/**
* Finds two pairs by looking for a pair, and them look if the remaining
* cards is a pair
*
* @param hand
* @return true if there is two pairs, otherwise false
*/
private boolean findTwoPairs(String hand) {
char[] values = getValues(hand);
@@ -72,6 +99,13 @@ public class PokerGame {
return false;
}
/**
* Finds Four of a kind by first finding Three of a kind and then looks if
* one of the remaining cards matches
*
* @param hand
* @return true if there is a Four of a kind, otherwise false
*/
private boolean findFourOfAKind(String hand) {
char[] values = getValues(hand);
@@ -84,17 +118,29 @@ public class PokerGame {
return false;
}
/**
* Finds a prison (kåk = prison). We have a prison if the first and last two
* cards are a pair, and the middle card has same value as either of them
* (is three of a kind)
*
* @param hand
* @return true if there is a prison, otherwise false
*/
private boolean findPrison(String hand) {
char[] values = getValues(hand);
// We have a prison if the first and last two cards are a pair, and the
// middle card has same value as either of them (is three of a kind)
if (values[0] == values[1] && values[3] == values[4]
&& (values[0] == values[2] || values[2] == values[3]))
return true;
return false;
}
/**
* Extracts all the values from the given String (hand)
*
* @param hand
* @return The values of all the cards
*/
private char[] getValues(String hand) {
char[] values = "".toCharArray();
String temp = "";