diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..feca8613 Binary files /dev/null and b/.DS_Store differ diff --git a/pom.xml b/pom.xml index c6ec0cc8..5afa7e8d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,16 +4,33 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.zipcoder + io.zipcoder.casino casino 1.0-SNAPSHOT + junit junit 4.12 - test - + + + 1.8 + 1.8 + 1.8 + + + + + + + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 00000000..9604c915 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 00000000..55c1fcbe Binary files /dev/null and b/src/main/.DS_Store differ diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store new file mode 100644 index 00000000..b7618dec Binary files /dev/null and b/src/main/java/.DS_Store differ diff --git a/src/main/java/io/zipcoder/casino/Bank.java b/src/main/java/io/zipcoder/casino/Bank.java new file mode 100644 index 00000000..9a07f94b --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Bank.java @@ -0,0 +1,25 @@ +package io.zipcoder.casino; + +public class Bank { + private Double balance; + + public double withdraw(double amount) { + if(sufficientFunds(amount)) { + balance -= amount; + return amount; + + }return 0; + } + + public void deposit(double amount) { + balance += amount; + } + + public Double getBalance() { + return balance; + } + + public boolean sufficientFunds(double amount){ + return amount <= this.balance; + } +} diff --git a/src/main/java/io/zipcoder/casino/BlackJack.java b/src/main/java/io/zipcoder/casino/BlackJack.java new file mode 100644 index 00000000..d1335ab2 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/BlackJack.java @@ -0,0 +1,63 @@ + +package io.zipcoder.casino; + +import java.util.ArrayList; + +public class BlackJack extends CardGame implements PlayForMoney { + private Bank house; + private Deck gameDeck; + BlackJackPlayer blackJackPlayer; + + ArrayList moneyfromPlayers = new ArrayList(); + + public ArrayList getDeckCards() { + + return null; + } + + public double betReceiveFromPlayers() { + + for(Double amountInGame: moneyfromPlayers){ + moneyfromPlayers.add(blackJackPlayer.getBet()); + return amountInGame; + } + return 0; + } + + public void resolveBets() { + } + + public void bet(CrapsBetType betType, double betAmount) { + + } + + public void takeBet(Double betAmount) { + + } + public void dealNewHand() { + + } + + public double betInplay() { + return 0; + } + + public void hand(Card card1, Card card2) { + + card1.getSuit(); + + } + + + public void scoreHand() { + + } + + public double makeBet(Double amount) { + return 0; + } + + public double collectWinnings(boolean isWin) { + return 0; + } +} diff --git a/src/main/java/io/zipcoder/casino/BlackJackDealer.java b/src/main/java/io/zipcoder/casino/BlackJackDealer.java new file mode 100644 index 00000000..c901e6b8 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/BlackJackDealer.java @@ -0,0 +1,4 @@ +package io.zipcoder.casino; + +//public class BlackJackDealer extends CardPlayer{ +//} diff --git a/src/main/java/io/zipcoder/casino/BlackJackPlayer.java b/src/main/java/io/zipcoder/casino/BlackJackPlayer.java new file mode 100644 index 00000000..9a7fd6e7 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/BlackJackPlayer.java @@ -0,0 +1,49 @@ +package io.zipcoder.casino; + +public class BlackJackPlayer extends CardPlayer implements PlayForMoney { + + private double bet; + + public BlackJackPlayer(String name) { + super(name); + } + + public void startGame(Deck deck) { + if (deck == null) { + throw new IllegalStateException("Deck is null"); + } + } + + public void setBet(double amount){ + this.bet = amount; + } + + public double getBet() { + return bet; + } + + public double showBalance() { + + return 0; + + } + + + public Card hit(Deck deck) { + return deck.pop(); + } + + public boolean stay() { + + return true; + } + + + public double makeBet(Double amount) { + return 0; + } + + public double collectWinnings(boolean isWin) { + return 0; + } +} diff --git a/src/main/java/io/zipcoder/casino/Card.java b/src/main/java/io/zipcoder/casino/Card.java new file mode 100644 index 00000000..c88dc6c9 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Card.java @@ -0,0 +1,31 @@ +package io.zipcoder.casino; + +public class Card { + private Suit suit; + private Rank rank; + + public Card(Rank rank,Suit suit){ + this.suit = suit; + this.rank = rank; + } + + + + + public Rank getRank() { + return rank; + } + + public Suit getSuit() { + return suit; + } + + + + @Override + public String toString() { + return rank.getSymbol() + suit.getCardSymbol(); + } + + +} diff --git a/src/main/java/io/zipcoder/casino/CardGame.java b/src/main/java/io/zipcoder/casino/CardGame.java new file mode 100644 index 00000000..b1dd2c03 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CardGame.java @@ -0,0 +1,31 @@ +package io.zipcoder.casino; + +import java.util.ArrayList; + +public class CardGame extends Game { + + private Deck gameDeck; + CardPlayer player = new CardPlayer(); + + + public CardGame(){ + + + + } + + + public void startPlayerTurn() { +// this. gameDeck = gameDeck; +// this.player = player; + } + + public Deck getGameDeck() { + Deck deck = new Deck(); + return deck; + } + +// public void setGameDeck(Deck gameDeck) { +// this.gameDeck = gameDeck; +// } +} diff --git a/src/main/java/io/zipcoder/casino/CardPlayer.java b/src/main/java/io/zipcoder/casino/CardPlayer.java new file mode 100644 index 00000000..68bd8530 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CardPlayer.java @@ -0,0 +1,21 @@ +package io.zipcoder.casino; + + +import java.util.ArrayList; + +public class CardPlayer extends Player{ + private ArrayList hand; + + public CardPlayer(String name) { + super(name); + } + + public CardPlayer(){ + super(); + this.hand = hand; + } + public ArrayList getHand() { + return hand; + } +} + diff --git a/src/main/java/io/zipcoder/casino/Casino.java b/src/main/java/io/zipcoder/casino/Casino.java index 74dfdd8c..c1b44b80 100644 --- a/src/main/java/io/zipcoder/casino/Casino.java +++ b/src/main/java/io/zipcoder/casino/Casino.java @@ -2,4 +2,9 @@ public class Casino { -} + private Game[] games; + + public static void main(String[] args) { + GoFish.goFishRun(); + } +} \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/Casino.uml b/src/main/java/io/zipcoder/casino/Casino.uml new file mode 100644 index 00000000..5e58d802 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Casino.uml @@ -0,0 +1,83 @@ + + + JAVA + io.zipcoder.casino.Casino + + io.zipcoder.casino.Casino + io.zipcoder.casino.Game + io.zipcoder.casino.Hand + io.zipcoder.casino.Card + io.zipcoder.casino.PlayForMoney + io.zipcoder.casino.CrapsPlayer + io.zipcoder.casino.Deck + io.zipcoder.casino.BlackJackPlayer + io.zipcoder.casino.Suit + io.zipcoder.casino.Player + io.zipcoder.casino.Craps + io.zipcoder.casino.BlackJack + io.zipcoder.casino.Rank + io.zipcoder.casino.GoFish + io.zipcoder.casino.GoFishPlayer + io.zipcoder.casino.Bank + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + io.zipcoder.casino.Hand + + + Fields + Methods + + All + private + + diff --git a/src/main/java/io/zipcoder/casino/Console.java b/src/main/java/io/zipcoder/casino/Console.java new file mode 100644 index 00000000..66350744 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Console.java @@ -0,0 +1,66 @@ + +package io.zipcoder.casino; + +import java.util.Scanner; +import java.util.WeakHashMap; + +import static io.zipcoder.casino.CrapsConsole.playCraps; +import static io.zipcoder.casino.GoFish.goFishRun; + +public class Console { + + public static void main(String[] args) { + + casinoHome(); + + } + + public static void casinoHome(){ + displayWelcomeMessage(); + selectGame(); + } + + + public static void selectGame() { + System.out.println("Which of our fine games would you like to try first?\n" + + "Enter 'blackjack' or 'b' to play BlackJack\n" + + "Enter 'craps' or 'c' to play Craps\n" + + "Enter 'GoFish or 'g to Go Fish.\n" + + "Type exit to quit"); + + Scanner scan = new Scanner(System.in); + String input; + do{ + input = scan.next(); + if(!input.equalsIgnoreCase("blackjack")&&!input.equalsIgnoreCase("b")&& + !input.equalsIgnoreCase("craps")&&!input.equalsIgnoreCase("c")&& + !input.equalsIgnoreCase("gofish")&&!input.equalsIgnoreCase("g")&& + !input.equalsIgnoreCase("exit")){ + System.out.println("I'm sorry that's not a valid entry"); + } + }while(!input.equalsIgnoreCase("blackjack")&&!input.equalsIgnoreCase("b")&& + !input.equalsIgnoreCase("craps")&&!input.equalsIgnoreCase("c")&& + !input.equalsIgnoreCase("gofish")&&!input.equalsIgnoreCase("g")&& + !input.equalsIgnoreCase("exit")); + + if(input.equalsIgnoreCase("blackjack")||input.equalsIgnoreCase("b")) { + // playBlackJack(); + } + else if(input.equalsIgnoreCase("craps")||input.equalsIgnoreCase("c")){ + playCraps(); + } + else if(input.equalsIgnoreCase("gofish")||input.equalsIgnoreCase("g")){ + goFishRun(); + }else if(input.equalsIgnoreCase("exit")){ + System.exit(0); + } + } + + + private static void displayWelcomeMessage() { + System.out.println("Welcome to our casino. Where the slots are are loose\n" + + "and the banker is liberal with credit\n"); + } + +} + diff --git a/src/main/java/io/zipcoder/casino/Craps.java b/src/main/java/io/zipcoder/casino/Craps.java new file mode 100644 index 00000000..dd2e2acc --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Craps.java @@ -0,0 +1,120 @@ + +package io.zipcoder.casino; + +import static io.zipcoder.casino.CrapsConsole.getBooleanInput; + +public class Craps extends Game implements PlayForMoney { + private Bank house; + + private CrapsBetType betType; + private Double playerBet; + private Integer point = 0; + + public void startPlayerTurn() { + } + + public void takeBet(Double betAmount) { + this.playerBet = betAmount; + } + + + public Double getPlayerBet() { + return playerBet; + } + + public void setPlayerBet(Double playerBet) { + this.playerBet = playerBet; + } + + public void setBetType(CrapsBetType betType) { + this.betType = betType; + } + + + public double resolveBet(CrapsPlayer crapsPlayer, boolean isWin) { + Double newWalletTotal; + if(isWin){ + Double walletAmount = crapsPlayer.getWallet(); + newWalletTotal = walletAmount + this.getPlayerBet(); + crapsPlayer.setWallet(newWalletTotal); + return newWalletTotal; + }else{ + Double walletAmount = crapsPlayer.getWallet(); + newWalletTotal = walletAmount - this.getPlayerBet(); + crapsPlayer.setWallet(newWalletTotal); + return newWalletTotal; + } + } + + public void setPoint(Integer point) { + this.point = point; + } + + public int getPoint() { + return point; + } + + public boolean isBetWinComeOut(int roll, CrapsBetType betType) { + if (betType == CrapsBetType.PASSLINE) + return (roll == 7 || roll == 11); + if (betType == CrapsBetType.DONTPASS) + return (roll == 2 || roll == 3); + return false; + + } + + public boolean isBetLossComeOut(int roll, CrapsBetType betType) { + if (betType == CrapsBetType.PASSLINE) + return (roll == 2 || roll == 3 || roll == 12); + if (betType == CrapsBetType.DONTPASS) + return (roll == 7 || roll == 11); + return false; + + } + + public CrapsBetType getBetType() { + return betType; + } + + public boolean isNoResultRoll(int roll, CrapsBetType betType) { + setPoint(roll); + return !isBetWinComeOut(roll, betType) && !isBetLossComeOut(roll, betType); + } + + public boolean isBetWin(int roll, CrapsBetType betType) { + if (betType == CrapsBetType.PASSLINE) + return (roll == this.point); + if (betType == CrapsBetType.DONTPASS) + return (roll == 7); + return false; + } + + public boolean isBetLoss(int roll, CrapsBetType betType) { + if(betType == CrapsBetType.PASSLINE) + return(roll==7); + if(betType == CrapsBetType.DONTPASS) + return(roll == this.point); + return (false); + } + + public double makeBet(Double amount) { + return 0; + } + + public double collectWinnings(boolean isWin) { + return 0; + } + + public void playerWins(CrapsPlayer crapsPlayer) { + System.out.println("You win!"); + Double newBalance = resolveBet(crapsPlayer, true); + System.out.println("Your new balance is " + newBalance + "!"); + } + + public void playerLoses(CrapsPlayer crapsPlayer) { + System.out.println("You lose:("); + Double newBalance = resolveBet(crapsPlayer, false); + System.out.println("Your new balance is " + newBalance + "."); + } +} + diff --git a/src/main/java/io/zipcoder/casino/CrapsBetType.java b/src/main/java/io/zipcoder/casino/CrapsBetType.java new file mode 100644 index 00000000..6b42afe5 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CrapsBetType.java @@ -0,0 +1,4 @@ +package io.zipcoder.casino; + +public enum CrapsBetType {PASSLINE, DONTPASS +} diff --git a/src/main/java/io/zipcoder/casino/CrapsConsole.java b/src/main/java/io/zipcoder/casino/CrapsConsole.java new file mode 100644 index 00000000..25ce0077 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CrapsConsole.java @@ -0,0 +1,158 @@ +package io.zipcoder.casino; + +import java.util.Scanner; + +import static io.zipcoder.casino.Console.selectGame; + +public class CrapsConsole { + + + public static void playCraps(){ + Craps craps = new Craps(); + CrapsPlayer crapsPlayer = new CrapsPlayer(); + + askIfPlayerWantsToPlay(); + boolean playGame = getBooleanInput(); + + while(playGame){ + + promptPlayerForBetType(); + craps.setBetType(getBetTypeInput()); + + promptPlayerForBet(); + craps.setPlayerBet(getEnforcedPositiveDoubleInput()); + + promptPlayerForRoll(); + Integer roll = crapsPlayer.roll2Dice(); + crapsPlayer.printRoll(); + + rollComeout(craps, crapsPlayer, roll); + + playGame = askPlayAgain(); + } + + selectGame(); + } + + + private static void rollPointRound(Craps craps, CrapsPlayer crapsPlayer, Integer roll) { + + craps.setPoint(roll); + System.out.println("Point is set at " + roll); + + while(true){ + promptPlayerForRoll(); + roll = crapsPlayer.roll2Dice(); + + crapsPlayer.printRoll(); + if(craps.isBetWin(roll, craps.getBetType())){ + craps.playerWins(crapsPlayer); + return; + }else if(craps.isBetLoss(roll, craps.getBetType())){ + craps.playerLoses(crapsPlayer); + return; + } + } + } + + private static void rollComeout(Craps craps, CrapsPlayer crapsPlayer, Integer roll) { + if(craps.isBetWinComeOut(roll, craps.getBetType())){ + craps.playerWins(crapsPlayer); + }else if (craps.isBetLossComeOut(roll, craps.getBetType())){ + craps.playerLoses(crapsPlayer); + }else { + rollPointRound(craps, crapsPlayer,roll); + } + } + + + private static void promptPlayerForRoll() { + System.out.println("Ready? Enter to roll"); + getUserInput(); + } + + private static void promptPlayerForBet() { + System.out.println("How much do you want to bet?"); + + } + + private static CrapsBetType getBetTypeInput() { + Scanner scan = new Scanner(System.in); + String input; + do{ + input = scan.next(); + if(!input.equalsIgnoreCase("pass")&&!input.equalsIgnoreCase("dont")){ + System.out.println("Please enter 'pass' or 'dont.'"); + } + }while(!input.equalsIgnoreCase("pass")&&!input.equalsIgnoreCase("dont")); + + if(input.equalsIgnoreCase("pass")){ + return CrapsBetType.PASSLINE; + }else if(input.equalsIgnoreCase("dont")){ + return CrapsBetType.DONTPASS; + } + + + return null; + } + + private static void promptPlayerForBetType() { + System.out.println("Enter 'pass' to bet the passline\nEnter 'dont'" + + " to bet against the passline."); + } + + private static void askIfPlayerWantsToPlay() { + System.out.println("Ready to play some craps? Win big with small dice!\n" + + "Feeling lucky...? 'y' or 'n'" ); + + } + + public static boolean getBooleanInput() { + Scanner scan = new Scanner(System.in); + String input; + do{ + input = scan.next(); + if(!input.equalsIgnoreCase("y")&&!input.equalsIgnoreCase("n")){ + System.out.println("Please enter 'y' or 'n.'"); + } + }while(!input.equalsIgnoreCase("y")&&!input.equalsIgnoreCase("n")); + return input.equalsIgnoreCase("y"); + } + + public static String getUserInput() { + Scanner scanner = new Scanner(System.in); + String input = scanner.nextLine(); + return input; + } + + public static double getEnforcedPositiveDoubleInput(){ + Scanner in = new Scanner(System.in); + double dInput; + String sInput; + do { + sInput = in.nextLine(); + if (!isInputDouble(sInput)||(Double.valueOf(sInput)<0)) { + System.out.println("Please enter a decimal number greater than 0."); + } + }while (!isInputDouble(sInput)||(Double.valueOf(sInput)<0)); + dInput=Double.valueOf(sInput); + return dInput; + } + + private static boolean isInputDouble(String passedString) + { + try { + Double output = Double.valueOf(passedString); + } catch (NumberFormatException e) { + return false; + } + return (true); + } + + private static boolean askPlayAgain() { + System.out.println("Play again?"); + return getBooleanInput(); + } + + +} diff --git a/src/main/java/io/zipcoder/casino/CrapsPlayer.java b/src/main/java/io/zipcoder/casino/CrapsPlayer.java new file mode 100644 index 00000000..3ad674e1 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CrapsPlayer.java @@ -0,0 +1,59 @@ +package io.zipcoder.casino; + +public class CrapsPlayer extends Player implements PlayForMoney { + private double walletAmount; + private Integer[] currentRoll = new Integer[2]; + + public CrapsPlayer(){ + super("A player has no name"); + this.walletAmount = 10000.0; + } + public CrapsPlayer(String name) { + super(name); + this.walletAmount = 10000.0; + } + + public Integer roll2Dice() { + + int rollOne = (int) (Math.random()*6)+1; + int rollTwo = (int) (Math.random()*6)+1; + + currentRoll[0] = rollOne; + currentRoll[1] = rollTwo; + + return rollOne+rollTwo; + } + + public void printRoll(){ + System.out.println("["+ currentRoll[0]+"," +currentRoll[1]+"]"); + } + + + + public double getWallet() { + return walletAmount; + } + + public void setWallet(double amount) { + this.walletAmount = amount; + } + + public double makeBet(Double amount) { + return 0; + } + + public double collectWinnings(boolean isWin) { + return 0; + } + + public double collectWinnings(boolean isWin, Craps craps) { + return 0; + } + + public void makeBet(Double amount, Craps craps) { + craps.setPlayerBet(amount); + + + } + +} diff --git a/src/main/java/io/zipcoder/casino/Deck.java b/src/main/java/io/zipcoder/casino/Deck.java new file mode 100644 index 00000000..733ada5f --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Deck.java @@ -0,0 +1,47 @@ +package io.zipcoder.casino; + +import sun.security.jca.GetInstance; + +import java.util.ArrayList; +import java.util.Collections; + +public class Deck { + private ArrayList cards; + + public Deck(){ + + cards = new ArrayList(); + + for (int i = 0; i < 4; i++) { + Suit[] suitArray = new Suit[]{Suit.CLUB, Suit.DIAMOND, Suit.HEART, Suit.SPADE}; + for (int j = 0; j < 13; j++) { + Rank[] rankArray = new Rank[]{Rank.ACE, Rank.TWO, Rank.THREE, Rank.FOUR, Rank.FIVE, + Rank.SIX, Rank.SEVEN, Rank.EIGHT, Rank.NINE, Rank.TEN, Rank.JACK, Rank.QUEEN, + Rank.KING}; + + Card card = new Card(rankArray[j], suitArray[i]); + + cards.add(card); + } + } + + } + + public ArrayList getDeck() { + return cards; + } + + public void shuffle() { + Collections.shuffle(cards); + } + + public Integer getDeckSize() { + return cards.size(); + } + + public Card pop() { + return null; + } +} + + diff --git a/src/main/java/io/zipcoder/casino/Game.java b/src/main/java/io/zipcoder/casino/Game.java new file mode 100644 index 00000000..b3d37f00 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Game.java @@ -0,0 +1,28 @@ +package io.zipcoder.casino; + +import java.util.ArrayList; + + + public class Game extends Exception { + private int playerTurn; + + private ArrayList players = new ArrayList(); + + public void startPlayerTurn(){}; + + public void addPlayer(Player player){ + players.add(player); + } + + public boolean isEndRound() { + return false; + } + + public void startGame(){ + + } + + public ArrayList getPlayers() { + return players; + } +} diff --git a/src/main/java/io/zipcoder/casino/GoFish.java b/src/main/java/io/zipcoder/casino/GoFish.java new file mode 100644 index 00000000..7fc1b5d8 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFish.java @@ -0,0 +1,47 @@ +package io.zipcoder.casino; + +import java.util.Scanner; + +import static io.zipcoder.casino.Console.casinoHome; + + +public class GoFish extends GoFishGame { + + + Scanner scanner = new Scanner(System.in); + + public static void goFishRun() { + + String response = "no"; + System.out.print("Welcome to the table!\n" + + "Insert nick name you want to use for the game? \n\n"); + + do { + + GoFishGame goFishGame = new GoFishGame(); + goFishGame.getGoFishPlayer().setName(InPutConsole.getInput()); + goFishGame.startGame(); + goFishGame.playerHand(); + goFishGame.computerHand(); + + while (!goFishGame.getDeck().isEmpty()) { + System.out.println("Insert the rank of the card you want to request: "); + String rank = InPutConsole.getInput(); + goFishGame.checkInput(rank); + goFishGame.askComputerHandForACard(rank); + goFishGame.playerHandDisplay(); + goFishGame.goFishingPlayer(); + goFishGame.checkIfComputerHandHasAcard(); + goFishGame.askPlayerForACard(goFishGame.computerCardToRequest()); + goFishGame.goFishingComputer(); + + } + + System.out.println("The game is over"); + goFishGame.decideWiner(); + System.out.println("Do you want to play again?"); + response = InPutConsole.getInput(); + } while (response.equalsIgnoreCase("yes")); + casinoHome(); + } +} diff --git a/src/main/java/io/zipcoder/casino/GoFishGame.java b/src/main/java/io/zipcoder/casino/GoFishGame.java new file mode 100644 index 00000000..5141fa91 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFishGame.java @@ -0,0 +1,454 @@ +package io.zipcoder.casino; + +import com.sun.tools.doclets.formats.html.SourceToHTMLConverter; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class GoFishGame extends CardGame { + + private ArrayList deck; + private GoFishPlayer goFishPlayer; + private ArrayList playerHand; + private ArrayList computerHand; + private GoFishPlayer computerPlayer; + + + public GoFishGame() { + this.goFishPlayer = new GoFishPlayer(); + this.deck = new Deck().getDeck(); + Collections.shuffle(deck); + this.playerHand = new ArrayList(); + this.computerHand = new ArrayList(); + this.computerPlayer = new GoFishPlayer(); + } + + + public void startGame() { + + + if (goFishPlayer == null || deck == null || playerHand == null) { + throw new IllegalStateException("Game tools doesnt exist"); + } + + } + + + public ArrayList playerHand() { + try { + int i = 0; + while (playerHand.size() != 7) { + playerHand.add(deck.get(i)); + deck.remove(i); + i++; + } + System.out.println("Here is your cards " + playerHand.toString() + + ". GoodLuck " + goFishPlayer.getName() + " !!!"); + return playerHand; + } catch (Exception e) { + System.out.println("no card in the deck"); + return null; + } + } + + + public ArrayList computerHand() { + int i = 0; + + + try { + if (getDeck().size() > 7) { + + while (computerHand.size() != 7) { + computerHand.add(deck.get(i)); + deck.remove(i); + i++; + } + } + + } catch (Exception e) { + } + + + return computerHand; + } + + + public ArrayList getPlayerHand() { + return playerHand; + } + + public ArrayList getDeck() { + return deck; + } + + public GoFishPlayer getGoFishPlayer() { + return goFishPlayer; + } + + + public void setDeck(ArrayList deck) { //used for testing purpose. Delete when done. + this.deck = deck; + } + + public Boolean checkComputerHandForPlayerRequestedCard(String rank) { + Boolean checkOutcome = false; + for (int i = 0; i < getComputerHand().size(); i++) { + if (rank.equals(getComputerHand().get(i).getRank().getSymbol())) + checkOutcome = true; + } + return checkOutcome; + } + + + public void askComputerHandForACard(String rank) { + ArrayList cards = new ArrayList<>(); + Card card = null; + while (checkComputerHandForPlayerRequestedCard(rank)) { + for (int i = 0; i < getComputerHand().size(); i++) { + card = getComputerHand().get(i); + if (rank.equals(card.getRank().getSymbol())) cards.add(card); + } + getPlayerHand().addAll(cards); + removeBookedCard(); + getComputerHand().removeAll(cards); + cards = new ArrayList<>(); + + System.out.println("The computer has " + rank + ".The card" + + " is added to your hand.\n Insert the next card you want: "); + + rank = InPutConsole.getInput(); + checkComputerHandForPlayerRequestedCard(rank); + + } + System.out.println("The computer doesnt have the card. Go Fish!!"); + } + + + public void goFishingPlayer() { + System.out.println(goFishPlayer.getName() + " is fishing"); + getPlayerHand().add(getDeck().get(0)); + getDeck().remove(0); + } + + + public void checkIfComputerHandHasAcard() { + getComputerHand(); + if (computerHand.size() == 0) + computerHand(); + } + + public String computerCardToRequest() { + int maxCount = 0; + int count = 0; + Card card = null; + try { + for (int i = 0; i < getComputerHand().size() - 1; i++) { + card = getComputerHand().get(i); + for (int j = i + 1; j < getComputerHand().size() - 1; j++) { + if (card.getRank() == getComputerHand().get(j).getRank()) { + count++; + } + } + if (count > maxCount) + + maxCount = count; + card = getComputerHand().get(i); + } + return card.getRank().getSymbol(); + } catch (Exception e) { + System.out.println("no card, sorry!"); + return ""; + } + } + + + public Boolean checkPlayerHasRequestedCardRank(String rank) { + rank = computerCardToRequest(); + Boolean checkOutcome = false; + for (int i = 0; i < getPlayerHand().size(); i++) { + if (rank.equals(getPlayerHand().get(i).getRank().getSymbol())) + checkOutcome = true; + } + return checkOutcome; + } + + + public ArrayList askPlayerForACard(String rank) { + System.out.println("The computer requested " + rank); + if (checkPlayerHasRequestedCardRank(rank)) { + ArrayList cards = new ArrayList<>(); + Card card = null; + while (checkPlayerHasRequestedCardRank(rank)) { + for (int i = 0; i < getPlayerHand().size(); i++) { + card = getPlayerHand().get(i); + if (rank.equals(card.getRank().getSymbol())) + cards.add(card); + + + } + System.out.println(goFishPlayer.getName() + " has " + rank + "." + + + "The card is added to the computer hand"); + getComputerHand().addAll(cards); + getPlayerHand().removeAll(cards); + removeComputerBookedCard(); + cards = new ArrayList<>(); + rank = computerCardToRequest(); + checkPlayerHasRequestedCardRank(rank); + } + } + System.out.println(goFishPlayer.getName() + " doesnt have " + rank + ". Go Fish!!"); + return getComputerHand(); + } + + public void goFishingComputer() { + try { + System.out.println("The computer is fishing"); + getComputerHand().add(getDeck().get(0)); + getDeck().remove(0); + } catch (Exception e) { + } + } + + public Map playerHandDisplay() { + // int score = player.getScore(); + + Map result = getPlayerHand() + .stream().map(card -> card.getRank().getSymbol()) + .collect(Collectors.groupingBy(Function.identity() , Collectors.counting())); + + System.out.println("You have " + result); + + return result; + + } + + public Integer countBooksInPlayerHand() { + ArrayList hand = getPlayerHand(); + List cardsByRank = new ArrayList<>(); + + for (Card card : hand) { + cardsByRank.add(card.getRank().getSymbol()); + } + + Set uniqueSet = new HashSet<>(cardsByRank); + Integer count = 0; + + for (String rank : uniqueSet) { + if (Collections.frequency(cardsByRank , rank) > 3) { + count++; + } + } + return count; + } + + public String playerHandCardToBeRemoved() { + ArrayList hand = getPlayerHand(); + List cardsByRank = new ArrayList<>(); + + for (Card card : hand) { + cardsByRank.add(card.getRank().getSymbol()); + } + + Set uniqueSet = new HashSet<>(cardsByRank); + Integer count = 0; + + for (String rank : uniqueSet) { + if (Collections.frequency(cardsByRank , rank) > 3) { + return rank; + } + } + return null; + } + + public Integer countBooksInComputerHand() { + Integer count = 0; + ArrayList hand = getComputerHand(); + List cardsByRank = new ArrayList<>(); + + for (Card card : hand) { + cardsByRank.add(card.getRank().getSymbol()); + } + + Set uniqueSet = new HashSet<>(cardsByRank); + + + for (String rank : uniqueSet) { + if (Collections.frequency(cardsByRank , rank) > 3) { + count++; + } + } + return count; + } + + + public Card checkPlayerHandForBook() { + int count = 0; + Card card = null; + ArrayList toBeRemoved = new ArrayList<>(); + + for (int i = 0; i < getPlayerHand().size(); i++) { + boolean found = false; + + for (int j = i + 1; !found && j < getPlayerHand().size(); j++) { + if (getPlayerHand().get(i).equals(getPlayerHand().get(j))) + found = true; + count++; + + if (count == 4) { + card = getPlayerHand().get(i); + int score = getGoFishPlayer().getScore() + 1; + goFishPlayer.setScore(score); + } + } + } + + + return card; + } + + public void removeBookedCard() { + try { + String cardTobeRemoved = playerHandCardToBeRemoved(); + + ArrayList tobeRemovedList = new ArrayList<>(); + Card card = null; + for (int i = 0; i < getPlayerHand().size(); i++) { + card = getPlayerHand().get(i); + if (card.getRank().getSymbol().equals(cardTobeRemoved)) + tobeRemovedList.add(card); + } + + getPlayerHand().removeAll(tobeRemovedList); + } catch (Exception e) { + } + + } + + public Card checkComputerHandForBook() { + int count = 0; + Card card = null; + + for (int i = 0; i < getComputerHand().size(); i++) { + boolean found = false; + + for (int j = i + 1; !found && j < getComputerHand().size(); j++) { + if (getComputerHand().get(i).equals(getComputerHand().get(j))) + found = true; + count++; + + if (count == 4) + card = getComputerHand().get(i); + } + } + + return card; + } + + public void removeComputerBookedCard() { + try { + String cardTobeRemoved = checkComputerHandForBook().getRank().getSymbol(); + ArrayList tobeRemovedList = new ArrayList<>(); + Card card = null; + for (int i = 0; i < computerHand().size(); i++) { + card = getComputerHand().get(i); + if (card.getRank().getSymbol().equals(cardTobeRemoved)) + tobeRemovedList.add(card); + } + + getComputerHand().removeAll(tobeRemovedList); + } catch (Exception e) { + System.out.println("card cant be removed"); + } + + } + + +// public Boolean checkPlayersCardRequestForInputBoundary(String input) { +// Boolean checkResult = false; +// public void checkPlayersCardRequestForInputBoundary(String input) { +// Boolean checkResult = true; +// if ((Integer.parseInt(input) > 2 && Integer.parseInt(input) < 12) +// || (input.toString().toUpperCase().equals("K")) +// || (input.toString().toUpperCase().equals("J")) || +// (input.toString().toUpperCase().equals("Q"))) { +// checkResult = true; +// checkPlayersCardRequestForGameRule(input); +// } else { +// checkResult = false; +// +// } +// +// +// return checkResult; +// +// } + + + public Boolean checkPlayersCardRequestForGameRule(String input) { + Boolean checkresult = false; + for (int i = 0; i < getPlayerHand().size(); i++) { + if (input.toUpperCase().equals(getPlayerHand().get(i).getRank().getSymbol())) { + checkresult = true; + break; + + } else { + + checkresult = false; + } + + } + + return checkresult; + + } + + public String checkInput(String input) { + Boolean checkResult = false; + + while (!checkPlayersCardRequestForGameRule(input)) { + System.out.println("Game rule: Insert card same rank as you have on your hand"); + input = InPutConsole.getInput(); + } + + return input; + + } + + + public void decideWiner() { + System.out.println("Computer score is " +countBooksInComputerHand() ); + System.out.println("Player score is " +countBooksInPlayerHand() ); + if (countBooksInComputerHand() > countBooksInPlayerHand()) + System.out.println(" The computer won"); + else if (countBooksInComputerHand() < countBooksInPlayerHand()) + System.out.println("Wow, you won! Congrats!!!"); + else if (countBooksInPlayerHand() == countBooksInComputerHand()) + System.out.println("The game is tie! try again"); + else + System.out.println("Sorry the score is not yet available. Please check again"); + } + + + public void setPlayerHand(ArrayList playerHand) { + this.playerHand = playerHand; + } + + public void setComputerHand(ArrayList computerHand) { + this.computerHand = computerHand; + } + + public ArrayList getComputerHand() { + return computerHand; + } + + public GoFishPlayer getComputerPlayer() { + return computerPlayer; + } + + +} + + diff --git a/src/main/java/io/zipcoder/casino/GoFishPlayer.java b/src/main/java/io/zipcoder/casino/GoFishPlayer.java new file mode 100644 index 00000000..5c49a9c8 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFishPlayer.java @@ -0,0 +1,73 @@ +package io.zipcoder.casino; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + + + public class GoFishPlayer extends CardPlayer { + private int score; + private String name; + private ArrayList hand; + + public GoFishPlayer(){super();} + + @Override + public int getScore() { + return score; + } + + @Override + public String getName() { + return name; + } + + @Override + public ArrayList getHand() { + return hand; + } + + @Override + public void setName(String name) { + this.name = name; + } + + @Override + public void setScore(int score) { + this.score = score; + } + // public Card drawCard(Deck deck) { +// Card playerCard = deck.getCards().remove(0); +// return playerCard; +// } +// +// public void addCardToHand(Card card){ +// getHand().add(card); +// } + +// public ArrayList getHand() { +// return hand; +// } +// +// public boolean checkHandForCard(Rank rank){ +// for(Card card: hand){ +// if(card.getRank() == rank) return true; +// }return false; +// +// } +// +// public Card giveCard(Rank rank){ +// for(Card card: hand){ +// if(card.getRank() == rank){ +// hand.remove(card); +// return card; +// } +// } +// return null; +// } +// +// public Suit checkFourOfAKind(){ +// +// // Stream handStream = hand.stream(). + +} diff --git a/src/main/java/io/zipcoder/casino/Hand.java b/src/main/java/io/zipcoder/casino/Hand.java new file mode 100644 index 00000000..628980c9 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Hand.java @@ -0,0 +1,4 @@ +package io.zipcoder.casino; + +public class Hand { +} diff --git a/src/main/java/io/zipcoder/casino/InPutConsole.java b/src/main/java/io/zipcoder/casino/InPutConsole.java new file mode 100644 index 00000000..ffc98070 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/InPutConsole.java @@ -0,0 +1,36 @@ +package io.zipcoder.casino; + +import java.util.Scanner; + +public class InPutConsole { + + static Scanner scanner = new Scanner(System.in); + + private InPutConsole() { + } + + public static String getInput(){ + + return scanner.nextLine(); + } + +// public static String getCardInput() { +// String input = ""; +// GoFishGame goFishGame = new GoFishGame(); +// input = scanner.nextLine().toUpperCase(); +// Boolean checkResult = false; +// while (checkResult == false) { +// if (goFishGame.checkPlayersCardRequestForGameRule(input)==true) { +// checkResult = true; +// break; +// } else { +// System.out.println("You cannot request for card not in hand. Insert the card you want "); +// input = scanner.nextLine().toUpperCase(); +// checkResult = false; +// } +// +// } +// return input; +// } +} + diff --git a/src/main/java/io/zipcoder/casino/Main.java b/src/main/java/io/zipcoder/casino/Main.java new file mode 100644 index 00000000..17589489 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Main.java @@ -0,0 +1,14 @@ + +package io.zipcoder.casino; + +import static io.zipcoder.casino.Console.casinoHome; + +public class Main { + + public static void main(String[] args) { + + + casinoHome(); + } +} + diff --git a/src/main/java/io/zipcoder/casino/PlayForMoney.java b/src/main/java/io/zipcoder/casino/PlayForMoney.java new file mode 100644 index 00000000..1d0b3ecb --- /dev/null +++ b/src/main/java/io/zipcoder/casino/PlayForMoney.java @@ -0,0 +1,8 @@ +package io.zipcoder.casino; + +public interface PlayForMoney { + + double makeBet(Double amount); + + double collectWinnings(boolean isWin); +} diff --git a/src/main/java/io/zipcoder/casino/Player.java b/src/main/java/io/zipcoder/casino/Player.java new file mode 100644 index 00000000..aca78ca5 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Player.java @@ -0,0 +1,46 @@ +package io.zipcoder.casino; + +public class Player { + private double bank; + private String name; + private int score; + + public Player(){ + + this.bank=bank; + this.name = name; + this.score= score; + } + + + public Player(String name) { + this.name = name; + } + + public void setBank(double bank) { + this.bank = bank; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public int getScore() { + return score; + } + + + public double getBank() { + return bank; + } + + + public void setScore(int score) { // only for test purpose, delete it later + this.score = score; + } + +} diff --git a/src/main/java/io/zipcoder/casino/Rank.java b/src/main/java/io/zipcoder/casino/Rank.java new file mode 100644 index 00000000..384febab --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Rank.java @@ -0,0 +1,44 @@ +package io.zipcoder.casino; + +public enum Rank +{ + ACE(11, "11"), + TWO(2, "2"), + THREE(3, "3"), + FOUR(4, "4"), + FIVE(5, "5"), + SIX(6, "6"), + SEVEN(7, "7"), + EIGHT(8, "8"), + NINE(9, "9"), + TEN(10, "10"), + JACK(10,"J"), + QUEEN(10, "Q"), + KING(10, "K"); + + private final int value; + private final String symbol; + + + Rank(int val, String symbol) { + this.value = val; + this.symbol = symbol; + } + + + public int getValue() { + return value; + } + + public String getSymbol() { + return symbol; + } + + @Override + public String toString() { + return "Rank{" + + "value=" + value + + '}'; + } +} + diff --git a/src/main/java/io/zipcoder/casino/SampleClass.java b/src/main/java/io/zipcoder/casino/SampleClass.java new file mode 100644 index 00000000..37d93d23 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/SampleClass.java @@ -0,0 +1,7 @@ +package io.zipcoder.casino; + +public class SampleClass { + public void myMethod() { + + } +} diff --git a/src/main/java/io/zipcoder/casino/Suit.java b/src/main/java/io/zipcoder/casino/Suit.java new file mode 100644 index 00000000..ee078f6f --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Suit.java @@ -0,0 +1,20 @@ +package io.zipcoder.casino; + +public enum Suit +{ + HEART( "♡"), + DIAMOND("♢"), + CLUB("♤"), + SPADE("♧"); + + private String cardSymbol; + + Suit( String cardSymbol) { + this.cardSymbol = cardSymbol; + } + + + public String getCardSymbol() { + return cardSymbol; + } +} \ No newline at end of file diff --git a/src/test/.DS_Store b/src/test/.DS_Store new file mode 100644 index 00000000..55c1fcbe Binary files /dev/null and b/src/test/.DS_Store differ diff --git a/src/test/java/io/zipcoder/casino/BlackJackPlayerTest.java b/src/test/java/io/zipcoder/casino/BlackJackPlayerTest.java new file mode 100644 index 00000000..c5f30b90 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/BlackJackPlayerTest.java @@ -0,0 +1,34 @@ +package io.zipcoder.casino; + + +// -As a blackjack player I want to place a bet on a blackjack hand. + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + + +public class BlackJackPlayerTest { + + BlackJack blackJack = new BlackJack(); + + @Test(expected = IllegalStateException.class) + public void shouldThrowIllegalStateExceptionWhenDeckIsNull() { + BlackJackPlayer blackJackPlayer = new BlackJackPlayer("el pato"); + Deck deck = null; + blackJackPlayer.startGame(deck); + Assert.assertNull(deck); + } + + @Test + public void placeBetTest() { + + BlackJackPlayer blackJackPlayer = new BlackJackPlayer("el pato"); + blackJackPlayer.setBet(10); + double actual = 10; + double expected = blackJack.betReceiveFromPlayers();// 10 + Assert.assertEquals(actual, expected, 0); + + } + +} diff --git a/src/test/java/io/zipcoder/casino/BlackJackTest.java b/src/test/java/io/zipcoder/casino/BlackJackTest.java new file mode 100644 index 00000000..7f05ff19 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/BlackJackTest.java @@ -0,0 +1,26 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class BlackJackTest { + + BlackJack blackJack = new BlackJack(); + + @Test + public void playersAddTest(){ + Player abrar = new Player("el pato"); + Player greg = new Player("el pato"); + blackJack.addPlayer(abrar); + blackJack.addPlayer(greg); + int expected = 2; + int actual = blackJack.getPlayers().size(); + Assert.assertEquals(expected, actual); + } + + + + +} diff --git a/src/test/java/io/zipcoder/casino/CrapsPlayerTest.java b/src/test/java/io/zipcoder/casino/CrapsPlayerTest.java new file mode 100644 index 00000000..b5617fc6 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/CrapsPlayerTest.java @@ -0,0 +1,41 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class CrapsPlayerTest { + + @Test + public void shouldReturnAValueBetween2AND12WhileRollingDiceTest(){ + + CrapsPlayer shooter = new CrapsPlayer("el pato"); + + Integer actual = shooter.roll2Dice(); + assertTrue(actual <13 && actual > 2); + } + + @Test + public void shouldIncreasePlayerWalletByBetWhenIsWin(){ + //given + Craps craps = new Craps(); + CrapsPlayer crapsPlayer = new CrapsPlayer("el pato"); + crapsPlayer.setWallet(500.0); + //when + crapsPlayer.makeBet(100.0); + boolean wins = craps.isBetWinComeOut(7, CrapsBetType.PASSLINE); + + craps.resolveBet(crapsPlayer, false); + crapsPlayer.collectWinnings(wins, craps); + + Double expected = 600.0; + Double actual = crapsPlayer.getWallet(); + + Assert.assertEquals(expected,actual); + + } + + + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/CrapsTest.java b/src/test/java/io/zipcoder/casino/CrapsTest.java new file mode 100644 index 00000000..35984e4a --- /dev/null +++ b/src/test/java/io/zipcoder/casino/CrapsTest.java @@ -0,0 +1,251 @@ + +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +public class CrapsTest { + + @Test + public void shouldAskPlayerTypeOfBet(){ + Craps craps = new Craps(); + CrapsPlayer crapsPlayer = new CrapsPlayer("el Pato"); + + CrapsBetType expected = CrapsBetType.PASSLINE; + craps.setBetType(CrapsBetType.PASSLINE); + + CrapsBetType actual = craps.getBetType(); + + } + @Test + public void shouldTakePlayerMoneyAndSetBetAmount(){ + Craps craps = new Craps(); + CrapsPlayer crapsPlayer = new CrapsPlayer("el Pato"); + + Double expected = 50.0; + craps.takeBet(expected); + + Double actual = craps.getPlayerBet(); + + Assert.assertEquals(expected,actual, 0); + } + + @Test + public void isWinOnComeRoll(){ + //given betType + Craps craps = new Craps(); + craps.setBetType(CrapsBetType.PASSLINE); + CrapsBetType passBet = craps.getBetType(); + + Assert.assertTrue(craps.isBetWinComeOut(7, passBet)); + Assert.assertTrue(craps.isBetWinComeOut(11, passBet)); + + craps.setBetType(CrapsBetType.DONTPASS); + CrapsBetType dontPassBet = craps.getBetType(); + + Assert.assertTrue(craps.isBetWinComeOut(2, dontPassBet)); + Assert.assertTrue(craps.isBetWinComeOut(3, dontPassBet)); + + + } + + @Test + public void isLossOnComeOutRoll(){ + //given betType + Craps craps = new Craps(); + craps.setBetType(CrapsBetType.DONTPASS); + CrapsBetType dontPass = craps.getBetType(); + + Assert.assertTrue(craps.isBetLossComeOut(7, dontPass)); + Assert.assertTrue(craps.isBetLossComeOut(11, dontPass)); + + craps.setBetType(CrapsBetType.PASSLINE); + CrapsBetType passBet = craps.getBetType(); + + Assert.assertTrue(craps.isBetLossComeOut(2, passBet)); + Assert.assertTrue(craps.isBetLossComeOut(3, passBet)); + Assert.assertTrue(craps.isBetLossComeOut(12,passBet)); + + + } + + @Test + public void isNeitherWinNorLossOnComeOut(){ + //given betType + Craps craps = new Craps(); + craps.setBetType(CrapsBetType.DONTPASS); + CrapsBetType dontPass = craps.getBetType(); + + Assert.assertTrue(craps.isNoResultRoll(4, dontPass)); + Assert.assertTrue(craps.isNoResultRoll(5, dontPass)); + Assert.assertTrue(craps.isNoResultRoll(6, dontPass)); + Assert.assertTrue(craps.isNoResultRoll(8, dontPass)); + Assert.assertTrue(craps.isNoResultRoll(9, dontPass)); + Assert.assertTrue(craps.isNoResultRoll(10, dontPass)); + Assert.assertTrue(craps.isNoResultRoll(12, dontPass)); + + craps.setBetType(CrapsBetType.PASSLINE); + CrapsBetType passBet = craps.getBetType(); + + Assert.assertTrue(craps.isNoResultRoll(4, passBet)); + Assert.assertTrue(craps.isNoResultRoll(5, passBet)); + Assert.assertTrue(craps.isNoResultRoll(6, passBet)); + Assert.assertTrue(craps.isNoResultRoll(8, passBet)); + Assert.assertTrue(craps.isNoResultRoll(9, passBet)); + Assert.assertTrue(craps.isNoResultRoll(10, passBet)); + + + } + + + + @Test + public void TestPointSetUponNoResultComeoutRoll(){ + + Craps craps = new Craps(); + craps.setBetType(CrapsBetType.DONTPASS); + CrapsBetType dontPass = craps.getBetType(); + + boolean flag = craps.isNoResultRoll(4, dontPass); + + Integer expected_point = 4; + Integer actual_point = craps.getPoint(); + + Assert.assertEquals(expected_point,actual_point); + + } + + @Test + public void determineIfPlayerWinsOrLosesAfterPointHasBeenSet(){ + //given betType, roll + Craps craps = new Craps(); + craps.setBetType(CrapsBetType.DONTPASS); + CrapsBetType dontPass = craps.getBetType(); + + boolean flag = craps.isNoResultRoll(4, dontPass); + + Assert.assertTrue(craps.isBetWin(7, CrapsBetType.DONTPASS)); + Assert.assertTrue(craps.isBetLoss(4, CrapsBetType.DONTPASS)); + Assert.assertTrue(craps.isBetLoss(5, CrapsBetType.DONTPASS)); + Assert.assertTrue(craps.isBetLoss(6, CrapsBetType.DONTPASS)); + + Assert.assertTrue(craps.isBetLoss(7, CrapsBetType.PASSLINE)); + Assert.assertTrue(craps.isBetWin(4, CrapsBetType.PASSLINE)); + } + + + + @Test + public void paysOutPlayerThatHasWon(){ + //given + Craps craps = new Craps(); + CrapsPlayer crapsPlayer = new CrapsPlayer("el pato"); + crapsPlayer.setWallet(500.0); + //when + crapsPlayer.makeBet(100.0, craps); + boolean wins = craps.isBetWinComeOut(7, CrapsBetType.PASSLINE); + + //then + double expected = 600; + double actual = craps.resolveBet(crapsPlayer, true); + + Assert.assertTrue(expected ==actual); + + } + + @Test + public void takeMoneyFromPlayerThatHasLost(){ + //given + Craps craps = new Craps(); + CrapsPlayer crapsPlayer = new CrapsPlayer("el pato"); + crapsPlayer.setWallet(500.0); + //when + crapsPlayer.makeBet(100.0, craps); + boolean flag = craps.isBetWinComeOut(7, CrapsBetType.PASSLINE); + double expected = 600; + double actual = craps.resolveBet(crapsPlayer,flag); + + //then + Assert.assertTrue(expected ==actual); + + } + + @Test + public void shouldReturnTrueIfDicesAreSevenOrEleven(){ + Craps craps = new Craps(); + craps.setBetType(CrapsBetType.PASSLINE); + CrapsBetType passBet = craps.getBetType(); + + assertEquals(true, craps.isBetWinComeOut(7, passBet)); + } + + + @Test + // as a craps player I would like to roll again if I my roll + // doesn't win or lose + public void rollAgainTest(){ + Craps craps = new Craps(); + Integer roll = 5; + + craps.setBetType(CrapsBetType.PASSLINE); + CrapsBetType passBet = craps.getBetType(); +// boolean flag = crapsGame.passBetLosesComeOut(roll); + boolean flag2 = craps.isBetWinComeOut(roll, passBet); + + // Assert.assertFalse(); + + } + + + //as a craps player would like to + + /* @Test + public void passBetWinsTest() throws Exception { + Craps game = new Craps(); + game.setComeOut(true); + Assert.assertTrue(game.passBetWinsComeOut(7)); + Assert.assertTrue(game.passBetWinsComeOut(11)); + + game.setPoint(9);; + Assert.assertTrue(game.passBetWins(9)); + + + } + + @Test + public void passBetLosesTest() throws Exception { + Craps game = new Craps(); + game.setComeOut(true); + Assert.assertTrue(game.passBetLosesComeOut(2)); + Assert.assertTrue(game.passBetLosesComeOut(3)); + Assert.assertTrue(game.passBetLosesComeOut(12)); + + game.setComeOut(false); + game.setPoint(4); + Assert.assertTrue(game.passBetLoses(7)); + }*/ + + @Test + public void dontPassWins() throws Exception { + } + + @Test + public void setBetType() throws Exception { + } + + @Test + public void placeBet() throws Exception { + } + + @Test + public void rollAgain() throws Exception { + } + + @Test + public void resolveBets() throws Exception { + } + +} diff --git a/src/test/java/io/zipcoder/casino/DeckTest.java b/src/test/java/io/zipcoder/casino/DeckTest.java new file mode 100644 index 00000000..583bb285 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/DeckTest.java @@ -0,0 +1,48 @@ + +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class DeckTest { + Deck deck = new Deck(); + + + @Test + public void constructorTest(){ + ArrayList cards = deck.getDeck(); + String expected = "a bunch of cards"; + String actual = "***output***\n "; + for(Card card: cards){ + actual +=(card.getRank() + " of " + card.getSuit()+"s\n"); + } + Assert.assertEquals(expected, actual); + } + + @Test + public void shuffleTest() throws Exception { + deck.shuffle(); + ArrayList cards = deck.getDeck(); + + String expected = "a bunch of cards"; + + String actual = "***output***\n"; + + for(Card card: cards){ + actual +=(card.getRank() + " of " + card.getSuit()+"s\n"); + } + + Assert.assertEquals(expected, actual); + + } + + public void testPop(){ + + } + + +} diff --git a/src/test/java/io/zipcoder/casino/GameTest.java b/src/test/java/io/zipcoder/casino/GameTest.java new file mode 100644 index 00000000..d94fb6cd --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GameTest.java @@ -0,0 +1,24 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import java.lang.reflect.Array; +import java.util.AbstractList; +import java.util.ArrayList; + +public class GameTest { + + Game game = new Game(); + + @Test + public void addPlayerTest() { + + Player raul = new Player("el pato"); + game.addPlayer(raul); + int expected = 1; + int actual = game.getPlayers().size(); + Assert.assertEquals(actual, expected); + + } +} diff --git a/src/test/java/io/zipcoder/casino/GoFishGameTest.java b/src/test/java/io/zipcoder/casino/GoFishGameTest.java new file mode 100644 index 00000000..7bb1594a --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFishGameTest.java @@ -0,0 +1,406 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Iterator; + +public class GoFishGameTest { + + GoFishGame goFishGame = new GoFishGame(); + Card card1 = new Card(Rank.TWO, Suit.CLUB); + Card card3 = new Card(Rank.THREE, Suit.SPADE); + Card card2 = new Card(Rank.TWO, Suit.SPADE); + Card card4 = new Card(Rank.THREE, Suit.CLUB); + Card card5 = new Card(Rank.TWO, Suit.HEART); + Card card6 = new Card(Rank.TWO, Suit.DIAMOND); + Card card7 = new Card(Rank.THREE, Suit.HEART); + Card card8 = new Card(Rank.THREE, Suit.SPADE); + ArrayList playerHand1 = new ArrayList<>(); + ArrayList computerHand1 = new ArrayList<>(); + + + @Test + public void createGoFishGameTest() throws Exception { + + int expected = 52; + int expected2 = 7; + int actual = goFishGame.getDeck().size(); + int actual2 = goFishGame.playerHand().size(); + + Assert.assertEquals(expected, actual); + Assert.assertEquals(expected2, actual2); + Assert.assertTrue(goFishGame.player instanceof Player); + + } + + @Test(expected = IllegalStateException.class) + public void shouldThrowExceptionWhenDeckIsNullStartingGame() { + goFishGame.setDeck(null); + GoFishPlayer goFishPlayer = new GoFishPlayer(); + goFishGame.startGame(); + } + + @Test + + public void playerHandget7CardStartOfGame() { + int expectedBeforeMethodCall = 0; + int actualBeforeMethodCall = goFishGame.getComputerHand().size(); + goFishGame.playerHand(); + int expectedPlayerHandSize = 7; + int actualPlayerHandSize = goFishGame.getPlayerHand().size(); + Assert.assertEquals(expectedBeforeMethodCall, actualBeforeMethodCall); + Assert.assertEquals(expectedPlayerHandSize, actualPlayerHandSize); + } + + @Test + + public void computerHandget7CardStartOfGame() { + int expectedBeforeMethodCall = 0; + int actualBeforeMethodCall = goFishGame.getComputerHand().size(); + + goFishGame.computerHand(); + + int expectedComputerHandSize = 7; + int actualComputerhandSize = goFishGame.getComputerHand().size(); + Assert.assertEquals(expectedBeforeMethodCall, actualBeforeMethodCall); + Assert.assertEquals(expectedComputerHandSize, actualComputerhandSize); + + } + + @Test + + public void getAndSetPlayerHandTest() { + playerHand1.add(card1); + playerHand1.add(card2); + goFishGame.setPlayerHand(playerHand1); + int expected = 2; + int actual = goFishGame.getPlayerHand().size(); + } + + @Test + + public void getAndSetComputerHand() { + playerHand1.add(card1); + playerHand1.add(card2); + playerHand1.add(card3); + goFishGame.setComputerHand(playerHand1); + int expected = 3; + int actual = goFishGame.getComputerHand().size(); + } + + @Test + public void deckSizeDecreaseAfterDeal() throws Exception { + goFishGame.getDeck(); + + int expectedBeforeDealing = 52; + int actualBeforeDealing = goFishGame.getDeck().size(); + + goFishGame.computerHand(); + goFishGame.playerHand(); + + int expectedAfterDealing = 52 - (goFishGame.getPlayerHand().size() + goFishGame.getComputerHand().size()); + int actualAfterDealing = goFishGame.getDeck().size(); + + Assert.assertEquals(expectedBeforeDealing, actualBeforeDealing); + Assert.assertEquals(expectedAfterDealing, actualAfterDealing); + } + + @Test + + public void playerHandDisplayAndSetPlayerHandTest() { + + ArrayList playerHand1 = new ArrayList<>(); + playerHand1.add(card1); + playerHand1.add(card2); + + goFishGame.setPlayerHand(playerHand1); + + String expected = "You have {2=1, 3=1}"; + String actual = goFishGame.playerHandDisplay().toString(); + + } + + + @Test + public void passingCardFromPlayerToComputerTest() { + + computerHand1.add(card1); + computerHand1.add(card2); + goFishGame.setComputerHand(computerHand1); + Boolean expected = true; + Boolean actual = goFishGame.checkComputerHandForPlayerRequestedCard("2"); + Boolean expected2 = false; + Boolean actual2 = goFishGame.checkPlayerHasRequestedCardRank("4"); + Assert.assertEquals(expected, actual); + Assert.assertEquals(expected2, actual2); + } + + @Test + + public void checkComputerHandForPlayerRequestedCardRank() { + computerHand1.add(card1); + computerHand1.add(card2); + computerHand1.add(card3); + + goFishGame.setComputerHand(computerHand1); + + Boolean expected = true; + Boolean actual = goFishGame.checkComputerHandForPlayerRequestedCard("2"); + + Assert.assertEquals(expected, actual); + } + +// @Test +// public void checkPlayerCanTakeCardFromComputerTest() { // tested by viewing the console and passed the test. +// goFishGame.getDeck(); +// goFishGame.playerHand(); +// Card card0 = new Card(Rank.SIX, Suit.SPADE); +// Card card = new Card(Rank.SEVEN, Suit.SPADE); +// +// +// ArrayList computerHand1 = new ArrayList<>(); +// computerHand1.add(card0); +// computerHand1.add(card); +// +// +// goFishGame.setComputerHand(computerHand1); +// +// String expected = " The computer has 7\nYour hand is [5♧, 10♤, 9♧, 3♧, 6♢, 9♢, J♧, 7♧]\n" + +// "Insert the next card you want: "; +// +// goFishGame.askComputerHandForACard("7"); +// } + + + @Test + + public void computerDecisionForCardTest() { + computerHand1.add(card5); + computerHand1.add(card1); + computerHand1.add(card6); + computerHand1.add(card3); + computerHand1.add(card4); + goFishGame.setComputerHand(computerHand1); + + String expected = "3"; + + String actual = goFishGame.computerCardToRequest(); + + Assert.assertEquals(expected, actual); + + } + +// @Test + +// public void checkPlayersCardRequestForInputBoundary() { +// Card card1 = new Card(Rank.SIX, Suit.HEART); +// Card card = new Card(Rank.SEVEN, Suit.DIAMOND); +// ArrayList playerHand1 = new ArrayList<>(); +// playerHand1.add(card1); +// playerHand1.add(card); +// +// goFishGame.setPlayerHand(playerHand1); +// Boolean expected = true; +// Boolean actual = goFishGame.checkPlayersCardRequestForInputBoundary("9"); +// Assert.assertEquals(expected, actual); +// Boolean expected2 = false; +// Boolean actual2 = goFishGame.checkPlayersCardRequestForInputBoundary("12"); +// Assert.assertEquals(expected2, actual2); +// } + + @Test + public void checkPlayersCardRequestForGameRuleTest() { + ArrayList playerHand1 = new ArrayList<>(); + playerHand1.add(card1); + playerHand1.add(card2); + + goFishGame.setPlayerHand(playerHand1); + + Boolean expected = false; + Boolean actual = goFishGame.checkPlayersCardRequestForGameRule("10"); + Assert.assertEquals(expected, actual); + + Boolean expected2 = true; + Boolean actual2 = goFishGame.checkPlayersCardRequestForGameRule("2"); + Assert.assertEquals(expected2, actual2); + } + + @Test + public void checkInputTest() { + ArrayList playerHand1 = new ArrayList<>(); + playerHand1.add(card1); + playerHand1.add(card3); + + goFishGame.setPlayerHand(playerHand1); + +// String expected = ""; +// String actual = goFishGame.checkInput("10"); // this test works but looping because the card isnt in the hand. +// Assert.assertEquals(expected, actual); + + String expected2 = "2"; + String actual2 = goFishGame.checkInput("2"); + Assert.assertEquals(expected2, actual2); + } + + @Test + + public void goFishingPlayerTest() { + ArrayList deck = goFishGame.getDeck(); + goFishGame.getPlayerHand(); + + Card card = deck.get(0); + int expectSizeOfHandIncreaseBy1AfterGoFish = goFishGame.getPlayerHand().size() + 1; + Boolean expectedDeckTopCardToBeAvailable = true; + Boolean actualDeckTopcardAvaialble = deck.contains(card); + + goFishGame.goFishingPlayer(); + + int actualSizeOfPlayerHandIncreaseAfterGoFish = goFishGame.getPlayerHand().size(); + Boolean expectedDeckTopCardNotToBeAvailable = false; + Boolean actualDeckTopCardNotToBeAvailable = deck.contains(card); + Assert.assertEquals(expectedDeckTopCardNotToBeAvailable, actualDeckTopCardNotToBeAvailable); + Assert.assertEquals(expectedDeckTopCardToBeAvailable, actualDeckTopcardAvaialble); + Assert.assertEquals(expectSizeOfHandIncreaseBy1AfterGoFish, actualSizeOfPlayerHandIncreaseAfterGoFish); + } + + @Test + + public void goFishingComputerTest() { + ArrayList deck = goFishGame.getDeck(); + goFishGame.getComputerHand(); + + Card card = deck.get(0); + int expectSizeOfComouterHandIncreaseBy1AfterGoFish = goFishGame.getComputerHand().size() + 1; + Boolean expectedDeckTopCardToBeAvailable = true; + Boolean actualDeckTopcardAvaialble = deck.contains(card); + + goFishGame.goFishingComputer(); + + int actualSizeOfComputerHandIncreaseAfterGoFish = goFishGame.getComputerHand().size(); + Boolean expectedDeckTopCardNotToBeAvailable = false; + Boolean actualDeckTopCardNotToBeAvailable = deck.contains(card); + Assert.assertEquals(expectedDeckTopCardNotToBeAvailable, actualDeckTopCardNotToBeAvailable); + Assert.assertEquals(expectedDeckTopCardToBeAvailable, actualDeckTopcardAvaialble); + Assert.assertEquals(expectSizeOfComouterHandIncreaseBy1AfterGoFish, actualSizeOfComputerHandIncreaseAfterGoFish); + + } + +// @Test +// +// public void playerHandBookTest(){ +// +// playerHand1.add(card1); +// playerHand1.add(card2); +// playerHand1.add(card3); +// playerHand1.add(card4); +// playerHand1.add(card5); +// playerHand1.add(card6); +// playerHand1.add(card7); +// +// int actual = 7; +// int expected1= playerHand1.size(); +// goFishGame.setPlayerHand(playerHand1); +// +// // goFishGame.checkPlayerHandForBook(); +// goFishGame.removeBookedCard(); +// System.out.println(goFishGame.countBooksInPlayerHand()); +// +// int actual2= playerHand1.size(); +// int expected =3; +// +// +// +// +// } + + @Test + public void countPlayerScoreTest() { + Player player = goFishGame.getGoFishPlayer(); + int score = 0; + Card card1 = new Card(Rank.TWO, Suit.CLUB); + Card card5 = new Card(Rank.THREE, Suit.SPADE); + Card card3 = new Card(Rank.TWO, Suit.DIAMOND); + Card card6 = new Card(Rank.THREE, Suit.CLUB); + Card card4 = new Card(Rank.TWO, Suit.SPADE); + Card card2 = new Card(Rank.THREE, Suit.HEART); + Card card7 = new Card(Rank.TWO, Suit.HEART); + Card card8 = new Card(Rank.THREE, Suit.SPADE); + + playerHand1.add(card1); + playerHand1.add(card2); + playerHand1.add(card3); + playerHand1.add(card4); + playerHand1.add(card5); + playerHand1.add(card6); + playerHand1.add(card7); + playerHand1.add(card8); + + goFishGame.setPlayerHand(playerHand1); + + + int expected = 2; + int actual = goFishGame.countBooksInPlayerHand(); + Assert.assertEquals(expected, actual); + } + + @Test + public void countComputerScoreTest() { + + } + + @Test + public void playerScoreTest () { + Player player = goFishGame.getGoFishPlayer(); + int score = 0; + Card card1 = new Card(Rank.TWO, Suit.CLUB); + Card card2 = new Card(Rank.TWO, Suit.HEART); + Card card3 = new Card(Rank.THREE, Suit.DIAMOND); + Card card4 = new Card(Rank.TWO, Suit.SPADE); + Card card5 = new Card(Rank.THREE, Suit.SPADE); + Card card6 = new Card(Rank.TWO, Suit.CLUB); + Card card7 = new Card(Rank.THREE, Suit.HEART); + Card card8 = new Card(Rank.THREE, Suit.SPADE); + + ArrayList playerHand1 = new ArrayList<>(); + + playerHand1.add(card1); + playerHand1.add(card2); + playerHand1.add(card3); + playerHand1.add(card4); + playerHand1.add(card5); + playerHand1.add(card6); + playerHand1.add(card7); + playerHand1.add(card8); + + goFishGame.setComputerHand(playerHand1); + int expected = 2; + int actual = goFishGame.countBooksInComputerHand(); + Assert.assertEquals(expected, actual); + } + @Test + public void decideWinnerTest () { + playerHand1.add(card1); + playerHand1.add(card2); + playerHand1.add(card3); + playerHand1.add(card4); + playerHand1.add(card5); + playerHand1.add(card6); + playerHand1.add(card7); + playerHand1.add(card8); + goFishGame.setComputerHand(playerHand1); + + goFishGame.countBooksInComputerHand(); + goFishGame.countBooksInPlayerHand(); + + goFishGame.decideWiner(); // should pop the machine won because the computer has 2 + // books(cards added to the computer hand) while the player hand is empty + + } + + } + + + + diff --git a/src/test/java/io/zipcoder/casino/GoFishPlayerTest.java b/src/test/java/io/zipcoder/casino/GoFishPlayerTest.java new file mode 100644 index 00000000..669d288f --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFishPlayerTest.java @@ -0,0 +1,32 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class GoFishPlayerTest { + + GoFishPlayer goFishPlayer = new GoFishPlayer(); + @Test + public void getAndSetScore() throws Exception { + + goFishPlayer.setScore(2); + + int expeted = 2; + + int actual = goFishPlayer.getScore(); + + Assert.assertEquals(expeted, actual); + } + + @Test + public void getAndSetName() throws Exception { + goFishPlayer.setName("me"); + String expected ="me"; + String actual = goFishPlayer.getName(); + Assert.assertEquals(expected,actual); + } + + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/GoFishTest.java b/src/test/java/io/zipcoder/casino/GoFishTest.java new file mode 100644 index 00000000..7db5be4f --- /dev/null +++ b/src/test/java/io/zipcoder/casino/GoFishTest.java @@ -0,0 +1,25 @@ +package io.zipcoder.casino; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class GoFishTest { + + GoFish goFish = new GoFish(); + @Test + + public void goFishObjectTest(){ + + Assert.assertTrue(goFish instanceof GoFishGame); + } + + @Test + public void goFishRun() throws Exception { + + goFish.goFishRun(); // should pop out Welcome to the table! insert nick name you want to use for the game? + // tested visually + } + +} \ No newline at end of file diff --git a/src/test/java/io/zipcoder/casino/HandTest.java b/src/test/java/io/zipcoder/casino/HandTest.java new file mode 100644 index 00000000..ab82b630 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/HandTest.java @@ -0,0 +1,13 @@ +package io.zipcoder.casino; + +import org.junit.Test; + +public class HandTest { + + Hand hand = new Hand(); + @Test + public void getCards(){ + + + } +} diff --git a/userStories b/userStories new file mode 100644 index 00000000..f66bd20c --- /dev/null +++ b/userStories @@ -0,0 +1,119 @@ +-As user I want to be able choose between blackjack, craps and go fish. +-As a user I want to set my profile. +-As a user I want to play anonymously. + +-As a blackjack player I want to place a bet on a blackjack hand. + +-As a blackjack player I want to play blackjack. + -As a blackjack player I want to start a game + test can create a game (Blackjack) + test can add a players to the game (Game) ok + test existance of a deck (BlackJack, Deck) + test existace of a hand (Blackjack, player) + - As a blackjack player I want to bet before I get the cards + test the bank balance of the player is sufficient to bet (BlackJack, Player) + and the player's pot in the game is increased (BlackJack) + the player money decrease by the bet amount (Player) + + + -As a blackjack player I want look at my cards. + test when the player deal/ hit, it can view the cards (Player) + + -As a blackjack player I want to know my bank account balance + test before you place a bet, it can check the balance (Player) + -As a blackjack player I want to hit so that I can get a card. + test when hit the player gets additional card (Player) + test the deck will remove the same card (Blackjack) + -As a blackjack player I would like to stand and see if I win my bet. + show sum of the player card when stands (Player) + check if the sum will beat the dealer (Blackjack) + + (As a blackjack player I would like to raise my bet if I have a good hand) + -As a blackjack player I would like to exit the game with my winnings. + test the player has all the money it win before exit (Player) + test the game return null value for the player after the player exist (BlackJack) + + +-As a blackjack dealer I would like to deal in a however many players would like to join my game. + test when the game starts the player/s receive cards (Player) +-As a blackjack dealer I would like to hit on everything up to 17. + test the dealer hit only if the score is less than 17 (Blackjack) +(As a blackjack dealer I would also like to hit on a "soft" 17, + i.e. a hand containing an ace and one or more other cards totaling six.) +-As a blackjack dealer I would like to reveal my cards at the end of each round. + test the hand of the dealer are visible for the player (dealer) +-As a blackjack dealer I would like to determine winners / loser / pushers at the end of each round. + test the highest score less than 22 win the game (Blackjack) + + +-As a gofish game customer I would like the game to start with a player, computer player and a deck + + test can create a game (GoFish) + test can add a players to the game (GoFish) + test existance of a deck (GoFish, Deck) + test existace of a hand (GoFish, GoFishPlayer) + +-As a gofish I would like to draw 7 cards (GoFish) + test that the player gets 7 cards from the deck at the start of the game + test that these cards are removed from the deck + test the layer is able to see the card + + -As a gofish I would like the computer to draw 7 cards and save it without displaying (GoFish) + test that the computer player gets 7 cards from the deck at the start of the game + test that these cards are removed from the deck + - As a gofish player I would like to be able to see my card + test console displayes players card + +-As a gofish player I would like to ask the computer for a particular card +and the compuetr should given me all cards at the hand of that type. + test compuetr pass the requested card and is removed from the computer hand + -As a go fish player, I want the computer to make smart decision, i.e. ask for the card that it has most. + -test the computer ask for the most frequent rank in its hand. + +-As a gofish player I would like to score a point when I have a book to lay down. + test for the number of cards of the same rank in the player hand + test I have 4 cards of the same Rank, I remove the cards from my hand + test my score incremented one point. + +-As a gofish player I would like to draw a card when my opponent doesn't have what I requested. + test I GoFish and draw a card from the deck + +-As a gofish player I would like to give a card that has been requested. + test the card is removed from my hand and it's add to the requested hand. +-As a gofish player I would like to see the final score when the deck is empty. + test which player has the biggest amount of points + + + + + +-As a craps player I would like to start the game. + test can add a players to the game (Game) + +-As a craps I bet on a dice roll + test the bank balance of the player is sufficient to bet (Craps, CrapsPlayer) + and the player's pot in the game is increased (Craps) + the player money decrease by the bet amount (Player) + +-As a craps player I want to roll the dice. + test dice are rolling and returning values + +-As craps player I would like to win my pass bet when I roll a 7 or 11 on the comeout. + test a sum of 7 or 11 in the first roll will win the game + test the money of the player increase by the amount of the bet +-As a craps player I would to like to lose my pass bet when I roll a 2, 3 or 12 on the comeout. + test 2,3,12 will make the player loose the game + test the money of the player decrease by the bet amount +-As a craps player I would like to win my pass bet when I have rolled anything but a 7, 11, 2, 3, 12, +to set a point and rolled that point. + test the player is able to roll the dice until it get a sum of the point or 7 + test the money of the player increase by the amount of the bet if the sum equals the point +-As a craps player I would like to lose my pass bet when when I have rolled anything but a 7, 11, 2, 3, 12, +to set a point and rolled 7 before my the set point. + test 7 will make the player loose the game + test the money of the player decrease by the bet amount +-As a craps player I would like to bet on the don't pass line. +(As a craps player I would like make "come" bets) +(As a craps player I would like make "don't come bets") +-As a craps player I would like take my winnings and go home. +(As a craps player I would like to borrow money from the casino when I run out.)