diff --git a/.gitignore b/.gitignore index 6161bf86..f20808bd 100644 --- a/.gitignore +++ b/.gitignore @@ -560,3 +560,6 @@ healthchecksdb MigrationBackup/ # End of https://www.gitignore.io/api/eclipse,intellij,netbeans,notepadpp,sublimetext,visualstudio + +# need to ignore +.DS_Store \ No newline at end of file diff --git a/Casino Cha-Chain UML.png b/Casino Cha-Chain UML.png new file mode 100644 index 00000000..4df279d8 Binary files /dev/null and b/Casino Cha-Chain UML.png differ diff --git a/src/main/java/com/github/zipcodewilmington/Casino.java b/src/main/java/com/github/zipcodewilmington/Casino.java index 5eae9ac0..c9f4b148 100644 --- a/src/main/java/com/github/zipcodewilmington/Casino.java +++ b/src/main/java/com/github/zipcodewilmington/Casino.java @@ -31,9 +31,9 @@ public void run() { if (isValidLogin) { String gameSelectionInput = getGameSelectionInput().toUpperCase(); if (gameSelectionInput.equals("SLOTS")) { - play(new SlotsGame(), new SlotsPlayer()); + play(new SlotsGame(), new SlotsPlayer(casinoAccount,console)); } else if (gameSelectionInput.equals("NUMBERGUESS")) { - play(new NumberGuessGame(), new NumberGuessPlayer()); + play(new NumberGuessGame(), new NumberGuessPlayer(casinoAccount, console)); } else { // TODO - implement better exception handling String errorMessage = "[ %s ] is an invalid game selection"; diff --git a/src/main/java/com/github/zipcodewilmington/casino/CardGame.java b/src/main/java/com/github/zipcodewilmington/casino/CardGame.java new file mode 100644 index 00000000..3925d49a --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/CardGame.java @@ -0,0 +1,49 @@ +package com.github.zipcodewilmington.casino; + +import com.github.zipcodewilmington.casino.cardutils.TheDeck; + +import java.util.ArrayList; +import java.util.HashMap; + +public abstract class CardGame implements GameInterface{ + ArrayList players; + TheDeck theDeck; + HashMap playerScores; + + // Constructors + public CardGame() { + players = new ArrayList<>(); + theDeck = new TheDeck(); + playerScores = new HashMap<>(); + } + + public TheDeck getTheDeck() { + return theDeck; + } + + public ArrayList getPlayers() { + return players; + } + + @Override + public void add(PlayerInterface player) { + players.add((CardPlayer) player); + playerScores.put((CardPlayer) player, 0); + } + + @Override + public void remove(PlayerInterface player) { + players.remove((CardPlayer) player); + playerScores.remove((CardPlayer) player); + } + + public void dealCards(int cardsForEach){ + for(int i = 0; i < cardsForEach; i++){ + // each round of dealing + for(CardPlayer cp : players){ + // for each player, give one card + cp.receiveCard(theDeck.drawCard()); + } + } + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/CardPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/CardPlayer.java new file mode 100644 index 00000000..5174648f --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/CardPlayer.java @@ -0,0 +1,83 @@ +package com.github.zipcodewilmington.casino; + +import com.github.zipcodewilmington.casino.cardutils.*; +import com.github.zipcodewilmington.utils.IOConsole; + +import java.util.Scanner; + +public abstract class CardPlayer extends PlayerClass{ + HandOfCards curHand; + + // Constructor + public CardPlayer(CasinoAccount wallet, IOConsole console){ + super(wallet, console); + curHand = new HandOfCards(); + } + public CardPlayer(HandOfCards hand){ + super(null, null); + curHand = hand; + } + + // my other functions + public HandOfCards getHandOfCards(){ + return curHand; + } + + public void receiveCard(PlayingCard pc){ + curHand.addCard(pc); + } + + public void useCard(PlayingCard pc){ + curHand.removeCard(pc); + } + + public void printHand(){ + // not sure what to put here yet so i'll leave it empty for now + super.printToConsole(curHand.toString()); + } + + public void clearHand(){ + curHand.clear(); + } + + public PlayingCard promptForCard(String prompt){ + String response = super.promptPlayerForChoice(prompt); + String[] cardPieces = response.toUpperCase().split(" "); + + PlayingCardValue pcv = parseCardValue(cardPieces); + PlayingCardSuit pcs = parseCardSuit(cardPieces); + + if(pcv == null || pcs == null){ + // or some exception??? dunno yet + return null; + } + return new PlayingCard(pcs, pcv); + } + + private PlayingCardSuit parseCardSuit(String[] cardPieces) { + for(String s : cardPieces){ + // iterating through the stuff split into spaces + for(PlayingCardSuit suit : PlayingCardSuit.values()){ + if(s.equals(suit.name())){ + return suit; + } + } + } + return null; + } + + private PlayingCardValue parseCardValue(String[] cardPieces) { + for(String s : cardPieces){ + // iterating through the stuff split into spaces + for(PlayingCardValue value : PlayingCardValue.values()){ + if(s.equals(value.toString())){ + return value; + } + } + } + return null; + } + + // abstract functions here + public abstract void sortHand(); +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 654c749b..68f6e2de 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -6,4 +6,34 @@ * The `ArcadeAccount` is used to log into the system to select a `Game` to play. */ public class CasinoAccount { -} + + private String accOwner; + private String accPassword; + private int accBalance; + + public CasinoAccount(String accOwner, String accPassword, int accBalance){ + this.accOwner = accOwner; + this.accPassword = accPassword; + this.accBalance = accBalance; + } + + public int getAccBalance() {return this.accBalance;} + + public void setAccBalance(int accBalance) { + this.accBalance = accBalance; + } + + public String getAccOwner() {return this.accOwner;} + + public void updateAccBalance(int winnings) { + this.accBalance = this.accBalance + winnings; + } + + public String getAccPassword() { + return accPassword; + } + + public void setAccPassword(String accPassword) { + this.accPassword = accPassword; + } +} \ No newline at end of file diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java index 2d09ec2a..b0def51c 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java @@ -1,21 +1,36 @@ package com.github.zipcodewilmington.casino; +import java.util.ArrayList; +import java.util.HashMap; + /** * Created by leon on 7/21/2020. * `ArcadeAccountManager` stores, manages, and retrieves `ArcadeAccount` objects * it is advised that every instruction in this class is logged */ public class CasinoAccountManager { + HashMap listOfAccounts = new HashMap<>(); + public HashMap getListOfAccounts() { + return listOfAccounts; + } + /** * @param accountName name of account to be returned * @param accountPassword password of account to be returned * @return `ArcadeAccount` with specified `accountName` and `accountPassword` */ public CasinoAccount getAccount(String accountName, String accountPassword) { - String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); - String currentClassName = getClass().getName(); - String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; - throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); +// String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); +// String currentClassName = getClass().getName(); +// String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; +// throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); + if(listOfAccounts.containsKey(accountName)){ + if(listOfAccounts.get(accountName).getAccPassword().equals(accountPassword)){ + return listOfAccounts.get(accountName); + } + } + String errorMessage = "There is no account with this name and password!"; + throw new RuntimeException(errorMessage); } /** @@ -26,10 +41,13 @@ public CasinoAccount getAccount(String accountName, String accountPassword) { * @return new instance of `ArcadeAccount` with specified `accountName` and `accountPassword` */ public CasinoAccount createAccount(String accountName, String accountPassword) { - String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); - String currentClassName = getClass().getName(); - String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; - throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); +// String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); +// String currentClassName = getClass().getName(); +// String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; +// throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); + CasinoAccount ca = new CasinoAccount(accountName, accountPassword, 1_000); + listOfAccounts.put(accountName, ca); + return ca; } /** @@ -38,9 +56,10 @@ public CasinoAccount createAccount(String accountName, String accountPassword) { * @param casinoAccount the arcadeAccount to be added to `this.getArcadeAccountList()` */ public void registerAccount(CasinoAccount casinoAccount) { - String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); - String currentClassName = getClass().getName(); - String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; - throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); +// String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName(); +// String currentClassName = getClass().getName(); +// String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented"; +// throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName)); + listOfAccounts.put(casinoAccount.getAccOwner(), casinoAccount); } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/GambleGameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GambleGameInterface.java new file mode 100644 index 00000000..dd905d49 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/GambleGameInterface.java @@ -0,0 +1,6 @@ +package com.github.zipcodewilmington.casino; + +public interface GambleGameInterface { + + int payOutCalc(int betAmount, int payOutMult); +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/GamblerInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GamblerInterface.java new file mode 100644 index 00000000..b37bdc02 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/GamblerInterface.java @@ -0,0 +1,13 @@ +package com.github.zipcodewilmington.casino; + +public interface GamblerInterface { + + int makeBet(int bet); + + boolean validBet(int bet); + + //The winnings from a bet going into the player's wallet + void depositPayOut(int winnings); + + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java index 9873f1ed..733d148e 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/GameInterface.java @@ -20,4 +20,8 @@ public interface GameInterface extends Runnable { * specifies how the game will run */ void run(); + + void printWinner(); + + boolean isEndCondition(); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/HouseAccount.java b/src/main/java/com/github/zipcodewilmington/casino/HouseAccount.java new file mode 100644 index 00000000..105b9d21 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/HouseAccount.java @@ -0,0 +1,33 @@ +package com.github.zipcodewilmington.casino; + +public class HouseAccount { + + private static HouseAccount houseAccount; + private int accBalance; + + private HouseAccount() { + accBalance = 1_000_000; + } + + public static synchronized HouseAccount getHouseAccount() { + if (houseAccount == null) { + houseAccount = new HouseAccount(); + } + return houseAccount; + } + + public int getBalance() { + return this.accBalance;} + + public int payout(int losses) { + //Casino is losing money + this.accBalance = accBalance - losses; + return losses; + } + + public void acceptMoney(int winnings) { + //Casino is gaining money + this.accBalance = accBalance + winnings; + } + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/PlayerClass.java b/src/main/java/com/github/zipcodewilmington/casino/PlayerClass.java new file mode 100644 index 00000000..cd3263cc --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/PlayerClass.java @@ -0,0 +1,73 @@ +package com.github.zipcodewilmington.casino; + +import com.github.zipcodewilmington.utils.IOConsole; + +public abstract class PlayerClass implements PlayerInterface { + + private CasinoAccount wallet; + private Integer totalGamesWon; + private Integer totalGamesPlayed; + private IOConsole playerInput; + + public PlayerClass(CasinoAccount wallet, Integer totalGamesWon, Integer totalGamesPlayed, IOConsole playerInput) { + this.wallet = wallet; + this.totalGamesWon = totalGamesWon; + this.totalGamesPlayed = totalGamesPlayed; + this.playerInput = playerInput; + } + + public PlayerClass(CasinoAccount wallet, IOConsole playerInput) { + this.wallet = wallet; + this.playerInput = playerInput; + this.totalGamesWon = 0; + this.totalGamesPlayed = 0; + } + + public Integer getWallet() { + return wallet.getAccBalance(); + } + + public void setWallet(CasinoAccount wallet) { + this.wallet = wallet; + } + + public CasinoAccount getCasinoAccount() { + return wallet; + } + + + public Integer getTotalGamesPlayed() { + return totalGamesPlayed; + } + + public void setTotalGamesPlayed(Integer totalGamesPlayed) { + this.totalGamesPlayed = totalGamesPlayed; + } + + public Integer getTotalGamesWon() { + return totalGamesWon; + } + + public void setTotalGamesWon(Integer totalGamesWon) { + this.totalGamesWon = totalGamesWon; + } + + public Double getWinRate() { + return (double) this.totalGamesWon / this.totalGamesPlayed * 100; + } + + public String promptPlayerForChoice(String promptChoiceString) { + String playerAnswer = playerInput.getStringInput(promptChoiceString); + + return playerAnswer; + } + + public Integer promptPlayerFoMoney(String money) { + Integer playerWantToSpend = playerInput.getIntegerInput(money); + return playerWantToSpend; + } + + public void printToConsole(String prompt) { + playerInput.println(prompt); + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java b/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java index c50b5113..d383856a 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java @@ -10,12 +10,14 @@ public interface PlayerInterface { /** * @return the `ArcadeAccount` used to log into the `Arcade` system to play this game */ - CasinoAccount getArcadeAccount(); + CasinoAccount getCasinoAccount(); /** * Defines how a specific implementation of `PlayerInterface` plays their respective game. + * * @param specify any return type you would like here * @return whatever return value you would like */ - SomeReturnType play(); + String play(); + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/RouletteGame.java b/src/main/java/com/github/zipcodewilmington/casino/RouletteGame.java new file mode 100644 index 00000000..adeaae6d --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/RouletteGame.java @@ -0,0 +1,39 @@ +package com.github.zipcodewilmington.casino; + +public class RouletteGame implements GameInterface{ + + private double payOutMult; + private RouletteTable table; + private PlayerInterface roulettePlayer; + private int ballCurrentNum; + + + public boolean winBet(String betParam) {return true;} + + public void endGame(){}; + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + + } + + @Override + public void printWinner() { + + } + + @Override + public boolean isEndCondition() { + return false; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/RouletteNumParam.java b/src/main/java/com/github/zipcodewilmington/casino/RouletteNumParam.java new file mode 100644 index 00000000..edd5e0c5 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/RouletteNumParam.java @@ -0,0 +1,58 @@ +package com.github.zipcodewilmington.casino; + +import java.util.HashMap; +import java.util.Map; + +public enum RouletteNumParam { + one(1, 1, 2, 2, 1, 1), + two(2, 2, 1, 1, 1, 2), + three(3, 1, 2, 1, 1, 3), + four(4, 2, 1, 1, 1, 1), + five(5, 1, 2, 1, 1,2), + six(6, 2, 1, 1, 1, 3), + seven(7, 1, 2, 1, 1, 1), + eight(8, 2, 1, 1, 1, 2), + nine(9, 1, 2, 1, 1, 3), + ten(10, 2, 1, 1, 1, 1), + eleven(11, 1, 1, 1, 1, 2), + twelve(12, 2, 2, 1, 1, 3), + thirteen(13, 1, 1, 1, 2, 1), + fourteen(14, 2, 2, 1, 2, 2), + fifteen(15, 1, 1, 1, 2, 3), + sixteen(16, 2, 2, 1, 2, 1), + seventeen(17, 1, 1, 1, 2, 2), + eighteen(18, 2, 2, 1, 2, 3), + nineteen(19, 1, 2, 2, 2, 1), + twenty(20, 2, 1, 2, 2, 2), + twenty_one(21, 1, 2, 2, 2, 3), + twenty_two(22, 2, 1, 2, 2, 1), + twenty_three(23, 1, 2, 2, 2, 2), + twenty_four(24, 2, 1, 2, 2, 3), + twenty_five(25, 1, 2, 2, 3, 1), + twenty_six(26, 2, 1, 2, 3, 2), + twenty_seven(27, 1, 2, 2, 3, 3), + twenty_eight(28, 2, 1, 2, 3, 1), + twenty_nine(29, 1, 1, 2, 3, 2), + thirty(30, 2, 2, 2, 3, 3), + thirty_one(31, 1, 1, 2, 3, 1), + thirty_two(32, 2, 2, 2, 3, 2), + thirty_three(33, 1, 1, 2, 3, 3), + thirty_four(34, 2, 2, 2, 3, 1), + thirty_five(35, 1, 1, 2, 3, 2), + thirty_six(36, 2, 2, 2, 3, 3); + int rouletteNum; + int oddOrEven; + int blackOrRed; + int highOrLow; + int whichDoz; + int whichColumn; +RouletteNumParam(int rouletteNum, int oddOrEven, int blackOrRed, int highOrLow, int whichDoz, int whichColumn) { + this.rouletteNum = rouletteNum; + this.oddOrEven = oddOrEven; + this.blackOrRed = blackOrRed; + this. highOrLow = highOrLow; + this.whichDoz = whichDoz; + this.whichColumn = whichColumn; +} + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/RouletteTable.java b/src/main/java/com/github/zipcodewilmington/casino/RouletteTable.java new file mode 100644 index 00000000..caecfd75 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/RouletteTable.java @@ -0,0 +1,12 @@ +package com.github.zipcodewilmington.casino; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +public class RouletteTable { + + private Random ball = new Random(); + HashMap numAssociation; + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/cardutils/HandOfCards.java b/src/main/java/com/github/zipcodewilmington/casino/cardutils/HandOfCards.java new file mode 100644 index 00000000..de815c4c --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/cardutils/HandOfCards.java @@ -0,0 +1,44 @@ +package com.github.zipcodewilmington.casino.cardutils; + +import java.util.ArrayList; + +public class HandOfCards extends ArrayList { + // Nullary Constructor + public HandOfCards() { + super(); + } + + /* + * Note: not sure how necessary these two functions are since the superclass, + * ArrayList already has these as methods + */ + // adds a card to your hand + public void addCard(PlayingCard pc){ + this.add(pc); + } + // removes a card from your hand + public void removeCard(PlayingCard pc){ + this.remove(pc); + } + + // checks for a specific value + public int howManyOfValue(PlayingCardValue targetValue){ + int count = 0; + for(PlayingCard pc : this){ + if(targetValue.equals(pc.getValue())){ + count++; + } + } + return count; + } + + // checks for a specific suit + public boolean containsSuit(PlayingCardSuit targetSuit){ + for(PlayingCard pc : this){ + if(targetSuit.equals(pc.getSuit())){ + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCard.java b/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCard.java new file mode 100644 index 00000000..13de6cb1 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCard.java @@ -0,0 +1,41 @@ +package com.github.zipcodewilmington.casino.cardutils; + +public class PlayingCard { + PlayingCardSuit suit; + PlayingCardValue value; + + // Constructors + public PlayingCard(PlayingCardSuit suit, PlayingCardValue value) { + this.suit = suit; + this.value = value; + } + + // Getters + public PlayingCardSuit getSuit() { + return suit; + } + public PlayingCardValue getValue() { + return value; + } + + // Other methods + /** + * same as Integer.compareTo(), but only for the card values + * @param otherCard + * @return neg = less than, 0 = equal to, or pos = greater than otherCard + */ + public int compareValue(PlayingCard otherCard){ + return this.value.compareTo(otherCard.getValue()); + } + + @Override + public String toString() { + return value + " of " + suit; + } + + @Override + public boolean equals(Object o) { + PlayingCard other = (PlayingCard) o; + return other.getSuit().equals(suit) && other.getValue().equals(value); + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardSuit.java b/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardSuit.java new file mode 100644 index 00000000..bf20124b --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardSuit.java @@ -0,0 +1,16 @@ +package com.github.zipcodewilmington.casino.cardutils; + +public enum PlayingCardSuit { + HEARTS("Hearts"), SPADES("Spades"), CLUBS("Clubs"), DIAMONDS("Diamonds"); + + private String name; + + PlayingCardSuit(String name) { + this.name = name; + } + + @Override + public String toString(){ + return name; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardValue.java b/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardValue.java new file mode 100644 index 00000000..253123d7 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardValue.java @@ -0,0 +1,24 @@ +package com.github.zipcodewilmington.casino.cardutils; + +public enum PlayingCardValue { + 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(11, "J"), QUEEN(12, "Q"), KING(13, "K"), ACE(14, "A"); + + private int numericalVal; + private String name; + + PlayingCardValue(int numVal, String name) { + this.numericalVal = numVal; + this.name = name; + } + + public int getNumericalVal() { + return numericalVal; + } + + @Override + public String toString(){ + return name; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/cardutils/TheDeck.java b/src/main/java/com/github/zipcodewilmington/casino/cardutils/TheDeck.java new file mode 100644 index 00000000..09eafd70 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/cardutils/TheDeck.java @@ -0,0 +1,52 @@ +package com.github.zipcodewilmington.casino.cardutils; + +import java.util.Random; +import java.util.Stack; + +public class TheDeck extends Stack{ + public TheDeck(){ + fillDeck(); + } + + private void fillDeck(){ + for(PlayingCardValue value : PlayingCardValue.values()) { + for(PlayingCardSuit suit : PlayingCardSuit.values()){ + this.push(new PlayingCard(suit, value)); + } + } + } + + public void reclaimCards(){ + this.clear(); + fillDeck(); + } + + /** + * Using the modern algorithm of Fisher-Yates shuffle + * The modern algorithm is more suited for computers + */ + public void shuffle(){ + Random rand = new Random(); + int n = this.size(); + + for(int i = 0; i < n - 2; i++){ + int j = rand.nextInt(n - i) + i; + PlayingCard temp = this.get(j); + this.set(j, this.get(i)); + this.set(i, temp); + } + } + + public PlayingCard drawCard(){ + return this.pop(); + } + + public boolean hasCardsLeft(){ + return !this.isEmpty(); + } + + // This getter is pretty much only for the tests + public PlayingCard[] getDeck(){ + return this.toArray(new PlayingCard[this.size()]); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java new file mode 100644 index 00000000..c9cf9082 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGame.java @@ -0,0 +1,144 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import com.github.zipcodewilmington.casino.CardGame; +import com.github.zipcodewilmington.casino.CardPlayer; +import com.github.zipcodewilmington.casino.GambleGameInterface; +import com.github.zipcodewilmington.casino.cardutils.HandOfCards; +import com.github.zipcodewilmington.casino.cardutils.PlayingCard; +import com.github.zipcodewilmington.casino.cardutils.PlayingCardValue; + +import java.util.HashMap; + +public class BlackJackGame extends CardGame implements GambleGameInterface { + DealerPlayer dealer; + HashMap betAmounts; + + public BlackJackGame(){ + super(); + dealer = new DealerPlayer(); + add(dealer); + } + + @Override + public void run() { + // deal 2 cards per player + dealCards(2); + + // make bets here + logPlayerBets(); + + // for each player, ask them how they wanna play + for(CardPlayer cp : super.getPlayers()){ + BlackJackPlayer temp = (BlackJackPlayer) cp; + if(!(temp instanceof DealerPlayer)) { + // play as long as you aren't the dealer + playerTurn(temp); + } + } + + // now the dealer takes their turn + dealer.play(); + + // now we can calculate each player's scores + decideWhoWinsAndPayThem(); + + // now do some clean up + betAmounts.clear(); + } + + public void playerTurn(BlackJackPlayer player) { + do{ + // while they wanna stay, play + String playerChoice = player.play(); + if(playerChoice.equals("HIT")){ + player.hitMe(this.getTheDeck().drawCard()); + if(player.isHandBusted()){ + player.printToConsole("YOU BUSTED! RIP"); + player.stay(); + } + } + else{ + player.stay(); + } + } while(!player.isStayOrNot()); + } + + void logPlayerBets() { + for(CardPlayer cp : super.getPlayers()) { + BlackJackPlayer temp = (BlackJackPlayer) cp; + int betValue; + do { + betValue = temp.promptPlayerFoMoney("How much do you wanna bet?"); + }while(temp.validBet(betValue)); + betAmounts.put(temp, betValue); + temp.makeBet(betValue); + } + } + + /* + * player busted = earn nothing gg + * dealer busted but player didn't bust = good job bruh + * dealer not busted but greater than player not busted = dealer win + */ + private void decideWhoWinsAndPayThem() { + // find the dealer's score + boolean busted = dealer.isHandBusted(); + int dealerScore = dealer.calculateScore(); + + for(CardPlayer cp : super.getPlayers()) { + BlackJackPlayer temp = (BlackJackPlayer) cp; + // now calculate funds + int payout = beatDealer(busted, dealerScore, temp) ? betAmounts.get(temp) : 0; + temp.depositPayOut(payout); + } + } + + public boolean beatDealer(boolean dealerBusted, int dealerScore, BlackJackPlayer player){ + // get the player's score + int playerScore = player.calculateScore(); + + if(player.isHandBusted()){ + return false; + } + else{ + if(dealerBusted){ + return true; + } + else if (dealerScore > playerScore) { + return false; + } + else{ + return true; + } + } + } + + @Override + public void printWinner() { + int dealerScore = dealer.calculateScore(); + // iterate over the players and see whose score is above the dealer + for(CardPlayer cp : getPlayers()){ + BlackJackPlayer player = (BlackJackPlayer) cp; + int playerScore = player.calculateScore(); + if(playerScore > dealerScore){ + // then they can get printed out? idk yet + } + } + + } + + @Override + public boolean isEndCondition() { + // the game of blackjack ends when the dealer has taken their turn + // not sure if we'll ever use this since run will never use this + return false; + } + + public int payOutCalc(int betAmount) { + return payOutCalc(betAmount, 2); + } + @Override + public int payOutCalc(int betAmount, int payOutMult) { + return betAmount * payOutMult; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackPlayer.java new file mode 100644 index 00000000..fd9a8315 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackPlayer.java @@ -0,0 +1,120 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import com.github.zipcodewilmington.casino.CardPlayer; +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.GamblerInterface; +import com.github.zipcodewilmington.casino.cardutils.HandOfCards; +import com.github.zipcodewilmington.casino.cardutils.PlayingCard; +import com.github.zipcodewilmington.casino.cardutils.PlayingCardValue; +import com.github.zipcodewilmington.utils.IOConsole; + +public class BlackJackPlayer extends CardPlayer implements GamblerInterface { + private boolean stayOrNot; + + public BlackJackPlayer(CasinoAccount wallet, IOConsole console) { + super(wallet, console); + stayOrNot = false; + } + + public BlackJackPlayer(HandOfCards hand) { + super(hand); + stayOrNot = false; + } + + // true means you decided to stay, false means you're good to keep going + public boolean isStayOrNot() { + return stayOrNot; + } + + public void setStayOrNot(boolean stayOrNot) { + this.stayOrNot = stayOrNot; + } + + @Override + public void sortHand() { + // this does nothing because there's nothing to sort + } + + @Override + public String play() { + // show the hand first + printHand(); + // now ask for input + String choice = promptPlayerForChoice("Would you like to get HIT or STAY?"); + if(choice.toUpperCase().equals("HIT") || choice.toUpperCase().equals("STAY")) { + return choice.toUpperCase(); + } + throw new RuntimeException("Not a VALID BlackJack option. SHAME!"); + } + + @Override + public void makeBet(int bet) { + // when we make a bet, we update our account with neg money + this.getCasinoAccount().updateAccBalance(-1 * bet); + } + + @Override + public boolean validBet(int bet) { + return this.getWallet() >= bet; + } + + @Override + public void depositPayOut(int winnings) { + this.getCasinoAccount().updateAccBalance(winnings); + } + + public void hitMe(PlayingCard pc){ + this.receiveCard(pc); + } + + public void stay(){ + stayOrNot = true; + } + + public int calculateScore(){ + int result = 0; + int aceCount = 0; + + // go through each of the cards in the hand + for(PlayingCard pc : getHandOfCards()){ + if(isFaceCard(pc)){ + // face cards are worth 10 + result += 10; + } + else if(!pc.getValue().equals(PlayingCardValue.ACE)){ + // not an ace + result += pc.getValue().getNumericalVal(); + } + else{ + aceCount++; + } + } + + // now deals with aces + for(int i = 0; i < aceCount; i++){ + if(busted(result + 11)){ + // busted if you add 11 means you add 1 + result += 1; + } + else{ + result += 11; + } + } + return result; + } + + // busted means you have more than 21 as your hand value + private boolean busted(int i) { + return (i > 21); + } + + public boolean isHandBusted() { + return busted(calculateScore()); + } + + // face cards are J, Q, K + private boolean isFaceCard(PlayingCard pc){ + PlayingCardValue val = pc.getValue(); + return (val.equals(PlayingCardValue.JACK) || val.equals(PlayingCardValue.QUEEN) || val.equals(PlayingCardValue.KING)); + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/DealerPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/DealerPlayer.java new file mode 100644 index 00000000..fde23b97 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/DealerPlayer.java @@ -0,0 +1,35 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +public class DealerPlayer extends BlackJackPlayer { + private boolean showFirstCard; + + public DealerPlayer() { + super(null, null); + showFirstCard = false; + } + + public boolean isShowFirstCard() { + return showFirstCard; + } + + public void setShowFirstCard(boolean showFirstCard) { + this.showFirstCard = showFirstCard; + } + + @Override + public String play() { + // make the decision + if(calculateScore() < 17){ + return "HIT"; + } + else{ + return "STAY"; + } + } + + @Override + public void printHand(){ + // HIDE THAT FIRST CARD! + } + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGame.java index 79570948..d2b440f2 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGame.java @@ -1,7 +1,93 @@ package com.github.zipcodewilmington.casino.games.numberguess; +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; + +import java.util.Scanner; + /** * Created by leon on 7/21/2020. */ -public class NumberGuessGame { +public class NumberGuessGame implements GameInterface{ + + private NumberGuessPlayer player; + + private int targetNumber; + + private int guess; + + private int guessesRemaining = 5; + + Scanner input = new Scanner(System.in); + + public int randomNum() { + int targetNumber = 1 + (int) (100 * Math.random()); + return targetNumber; + } + + public void makeGuess(int guess) { + System.out.println("Enter your guess: "); + guess = input.nextInt(); + + } + + public boolean validateGuess() { + if (guess == targetNumber) { + printWinner(); + return true; + } else if (guess > targetNumber) { + System.out.println("Your guess is too high :("); + return false; + } else { + System.out.println("Your guess is too low :("); + } + return false; + } + + public void getRemainingGuesses() { + do { + System.out.println("You have " + guessesRemaining + " guesses remaining"); + guessesRemaining--; + } while (guessesRemaining > 0); + + } + + @Override + public void add(PlayerInterface player) { + this.player = (NumberGuessPlayer) player; + } + + @Override + public void remove(PlayerInterface player) { + this.player = null; + } + + @Override + public void run() { + randomNum(); + System.out.println("I'm thinking of a number between 1 and 100.\nYou have 5 tries to guess the number.\nGood luck :)"); + do { + makeGuess(this.guess); + getRemainingGuesses(); + validateGuess(); + } while (!isEndCondition()); + isEndCondition(); + + + + } + + @Override + public void printWinner() { + System.out.println("You guessed the number!\nYou win!"); + + } + + @Override + public boolean isEndCondition() { + if (guessesRemaining == 0) { + System.out.println("You ran out of tries :(\nYou lose!"); + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayer.java index aa5cce2e..02532e01 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayer.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayer.java @@ -1,7 +1,61 @@ package com.github.zipcodewilmington.casino.games.numberguess; +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.PlayerClass; +import com.github.zipcodewilmington.utils.IOConsole; + /** * Created by leon on 7/21/2020. */ -public class NumberGuessPlayer { +public class NumberGuessPlayer extends PlayerClass{ + + private int playerScore = 0; + private int totalGames; + + public NumberGuessPlayer(CasinoAccount wallet, IOConsole playerInput) { + super(wallet, playerInput); + } + + + public void setPlayerScore(int playerScore) { + this.playerScore = playerScore; + } + + public int getTotalGames() { + return totalGames; + } + + public void setTotalGames(int totalGames) { + this.totalGames = totalGames; + } + + public void incrementScore() { + playerScore++; + } + + public int getScore() { + return playerScore; + } + + public double calcWinRate(int totalGames) { + return (double) 100 * ((double) playerScore / totalGames); + } + + public void updateGame(boolean isEndCondition) { + if (true) { + this.totalGames++; + } + + } + + public void displayPlayerInfo() { + System.out.println(playerScore); + System.out.println(totalGames); + System.out.println((calcWinRate(totalGames))); + } + + @Override + public String play() { + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java index 8cb20c78..3c406e22 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsGame.java @@ -1,7 +1,138 @@ package com.github.zipcodewilmington.casino.games.slots; +import com.github.zipcodewilmington.casino.*; +import com.github.zipcodewilmington.utils.IOConsole; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + /** * Created by leon on 7/21/2020. */ -public class SlotsGame { +public class SlotsGame implements GambleGameInterface, GameInterface { + private SlotsPlayer playerOfSlots; + private Integer [] numbersTable ; + private Integer resultOfSpin ; + + + @Override + public int payOutCalc(int betAmount, int payOutMult) { + int temp = betAmount * payOutMult; + return temp; + } + + +// public Integer[] userInput() { +// int counter = 0; +// String promptToPlayer = "Enter your numbers"; +// Integer[] userInput = new Integer[3]; +// for (int i = 0; i < 3; i++) { +// System.out.println("You can enter " + counter + "numbers not higher than 100"); +// userInput[i] = playerInput.getIntegerInput(promptToPlayer); +// counter++; +// }return userInput(); +// } + @Override + public void run() { + String startGameString = "Hello , type SPACE to start the Game and try your luck"; + + boolean runGame = true; + + while (runGame) { + add(playerOfSlots); + System.out.println(startGameString); + checkThePlayerv(playerOfSlots); + machineSpin(); + checkingWinningCondition(resultOfSpin); + if (!isEndCondition()) {runGame = false;} + + } +} + + + + + public void machineSpin() { + + Random rand1 = new Random(10); + Random rand2 = new Random(10); + Random rand3 = new Random(10); + Random rand4 = new Random(10); + Random rand5 = new Random(10); + + newTable.add(rand1.nextInt()); + newTable.add(rand2.nextInt()); + newTable.add(rand3.nextInt()); + newTable.add(rand4.nextInt()); + newTable.add(rand5.nextInt()); + + // for (Integer num : userInput()) { +// userInputList.add(num); +// } + + int counterOccur = 0; + int counterResult = 0; + + for (int i = 0 ; i < newTable.size(); i++) { + int ckeck = newTable.get(i); + int counterFreq = 0; + for (int j = 0 ; j < newTable.size() ; j++) { + + if (newTable.get(i).equals(newTable.get(j))) { + counterFreq++; + } + } + if ( counterFreq > counterOccur) { + counterOccur = counterFreq; + } + } + resultOfSpin = counterOccur; + } + + public boolean checkingWinningCondition (Integer resultOfSpin) { + if (resultOfSpin >= 3 && resultOfSpin <= 5 ) { + System.out.println("Congratulations! Your numbers match!!! YOUR multiplier IS " + resultOfSpin); + return true; + } + else {System.out.println("Sorry, the numbers do not match."); + } + return false; + } + + public void endOfGame () { + } + + public void checkThePlayerv(SlotsPlayer player) { + playerOfSlots.validBet(0); + playerOfSlots.makeBet(0); + } + + + private ArrayList newTable = new ArrayList<>(Arrays.asList(numbersTable)); + ArrayList userInputList = new ArrayList<>(); + + @Override + public void add(PlayerInterface player) { + playerOfSlots = (SlotsPlayer) player; + + } + + @Override + public void remove(PlayerInterface player) { + } + + + @Override + public void printWinner() { + + } + + @Override + public boolean isEndCondition() { + if( playerOfSlots.getWallet() <= 0 ) { + return true; + } else {checkThePlayerv(playerOfSlots);} + return false; + } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java index f89ebd7f..2f5a46b0 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java +++ b/src/main/java/com/github/zipcodewilmington/casino/games/slots/SlotsPlayer.java @@ -1,7 +1,44 @@ -package com.github.zipcodewilmington.casino.games.slots; - -/** - * Created by leon on 7/21/2020. - */ -public class SlotsPlayer { -} \ No newline at end of file +package com.github.zipcodewilmington.casino.games.slots; + + +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.GamblerInterface; +import com.github.zipcodewilmington.casino.PlayerClass; +import com.github.zipcodewilmington.utils.IOConsole; +import java.util.Random; + +/** + * Created by leon on 7/21/2020. + */ +public class SlotsPlayer extends PlayerClass implements GamblerInterface { + + public SlotsPlayer(CasinoAccount wallet, IOConsole playerInput) { + super(wallet, playerInput); + } + + @Override + public int makeBet(int bet) { + if (validBet(bet)) { + } + return bet; + } + + @Override + public boolean validBet(int bet) { + if (getWallet() > bet) { + return true; + } + return false; + } + + @Override + public void depositPayOut(int winnings) { + + } + + @Override + public SomeReturnType play() { + return null; + } + +} diff --git a/src/test/java/com/github/zipcodewilmington/ApplicationRunnerTest.java b/src/test/java/com/github/zipcodewilmington/ApplicationRunnerTest.java index a9af8209..0db2c8c3 100644 --- a/src/test/java/com/github/zipcodewilmington/ApplicationRunnerTest.java +++ b/src/test/java/com/github/zipcodewilmington/ApplicationRunnerTest.java @@ -18,4 +18,5 @@ public void test() { // TODO - replace boiler-plate logic with business logic // then Assert.assertNotNull(runnable.toString()); } + } diff --git a/src/test/java/com/github/zipcodewilmington/casino/CasinoAccountTest.java b/src/test/java/com/github/zipcodewilmington/casino/CasinoAccountTest.java new file mode 100644 index 00000000..ffc775a9 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/CasinoAccountTest.java @@ -0,0 +1,68 @@ +//package com.github.zipcodewilmington.casino; +// +//import com.github.zipcodewilmington.Casino; +//import org.junit.Assert; +//import org.junit.jupiter.api.Test; +// +//import static org.junit.jupiter.api.Assertions.*; +// +//class CasinoAccountTest { +// +// @Test +// void getAccBalance() { +// //Given +// CasinoAccount bob = new CasinoAccount("Bob", 5_000); +// +// //When +// int expectedNum = bob.getAccBalance(); +// int actualNum = 5_000; +// +// //Then +// Assert.assertEquals(expectedNum, actualNum); +// +// } +// +// @Test +// void setAccBalance() { +// //Given +// CasinoAccount fred = new CasinoAccount("Fred", 100); +// fred.setAccBalance(3_000); +// +// //When +// int expectedNum = fred.getAccBalance(); +// int actualNum = 3_000; +// +// //Then +// Assert.assertEquals(expectedNum, actualNum); +// +// } +// +// @Test +// void getAccOwner() { +// //Given +// CasinoAccount jawn = new CasinoAccount("Jawn", 100); +// +// //When +// String expectdOwner = "Jawn"; +// String actualOwner = jawn.getAccOwner(); +// +// //Then +// Assert.assertEquals(expectdOwner, actualOwner); +// +// } +// +// @Test +// void updateAccBalance() { +// //Given +// CasinoAccount sam = new CasinoAccount("Sam", 100); +// sam.updateAccBalance(100); +// +// //When +// int expectedNum = 200; +// int actualNum = sam.getAccBalance(); +// +// //Then +// Assert.assertEquals(expectedNum, actualNum); +// +// } +//} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/HouseAccountTest.java b/src/test/java/com/github/zipcodewilmington/casino/HouseAccountTest.java new file mode 100644 index 00000000..e81c599c --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/HouseAccountTest.java @@ -0,0 +1,51 @@ +package com.github.zipcodewilmington.casino; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +import com.github.zipcodewilmington.casino.HouseAccount; + +class HouseAccountTest { + @Test + void testAll(){ + getBalance(); + acceptMoney(); + payout(); + } + + void getBalance() { + //Given + HouseAccount houseAccount = HouseAccount.getHouseAccount(); + //When + int expected = houseAccount.getBalance(); + int actual = 1_000_000; + + //Then + Assert.assertEquals(expected, actual); + } + + void payout() { + //Given + HouseAccount houseAccount = HouseAccount.getHouseAccount(); + houseAccount.payout(30); + //When + int expected = houseAccount.getBalance(); + int actual = 1_000_000 + 40 - 30; + //Then + Assert.assertEquals(expected, actual); + } + + void acceptMoney() { + //Given + HouseAccount houseAccount = HouseAccount.getHouseAccount(); + houseAccount.acceptMoney(40); + //When + int expected = houseAccount.getBalance(); + int actual = 1_000_000 + 40; + + //Then + Assert.assertEquals(expected, actual); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/PlayerTests.java b/src/test/java/com/github/zipcodewilmington/casino/PlayerTests.java new file mode 100644 index 00000000..baf860ee --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/PlayerTests.java @@ -0,0 +1,57 @@ +package com.github.zipcodewilmington.casino; + +import org.junit.Assert; +import org.junit.Test; + +//public class PlayerTests { +// +// @Test +// public void testGetWallet() { +// //Given +// CasinoAccount wallet = new CasinoAccount("Brent", 5600); +// +// PlayerClass brent = new PlayerClass(wallet, null, null, null); +// +// Integer expected = wallet.getAccBalance(); +// +// //When +// Integer actual = brent.getWallet(); +// +// //Then +// Assert.assertEquals(expected, actual); +// } +// +// @Test +// public void testTotalGamesWon() { +// //Given +// CasinoAccount wallet = new CasinoAccount("Brent", 5600); +// +// PlayerClass brent = new PlayerClass(wallet, 12, 15, null); +// +// +// //When +// Integer expected = 12; +// Integer actual = brent.getTotalGamesWon(); +// +// //Then +// Assert.assertEquals(expected, actual); +// +// } +// +// @Test +// public void testTotalGamesPlayed() { +// //Given +// CasinoAccount wallet = new CasinoAccount("Brent", 5600); +// +// PlayerClass brent = new PlayerClass(wallet, 12, 15, null); +// +// +// //When +// Integer expected = 15; +// Integer actual = brent.getTotalGamesPlayed(); +// +// //Then +// Assert.assertEquals(expected, actual); +// +// } +//} diff --git a/src/test/java/com/github/zipcodewilmington/casino/cardutils/HandOfCardsTest.java b/src/test/java/com/github/zipcodewilmington/casino/cardutils/HandOfCardsTest.java new file mode 100644 index 00000000..1c60688c --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/cardutils/HandOfCardsTest.java @@ -0,0 +1,99 @@ +package com.github.zipcodewilmington.casino.cardutils; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class HandOfCardsTest { + /* + * Note: this test is unnecessary, but I wrote it in to test if I understood how extension works + * I also do think this works only because I implemented .equals() for PlayingCard + */ + @Test + public void containsTest(){ + // Given + HandOfCards curHand = new HandOfCards(); + curHand.add(new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE)); + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + // When + boolean actual = curHand.contains(pc); + // Then + assertEquals(true, actual); + } + + @Test + public void addCardTest() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + HandOfCards curHand = new HandOfCards(); + curHand.addCard(pc); + // When + boolean actual = curHand.contains(pc); + // Then + assertEquals(true, actual); + } + + @Test + public void removeCardTest() { + // Given + int expectedSize = 2; + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + PlayingCard pc1 = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.ACE); + PlayingCard pc2 = new PlayingCard(PlayingCardSuit.CLUBS, PlayingCardValue.ACE); + HandOfCards curHand = new HandOfCards(); + curHand.addCard(pc); + curHand.addCard(pc1); + curHand.addCard(pc2); + // When + curHand.removeCard(pc1); + // Then + assertEquals(false, curHand.contains(pc1)); + assertEquals(expectedSize, curHand.size()); + } + + @Test + public void howManyOfValueTest() { + // Given + int expected = 4; + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + PlayingCard pc1 = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.ACE); + PlayingCard pc2 = new PlayingCard(PlayingCardSuit.CLUBS, PlayingCardValue.ACE); + PlayingCard pc3 = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.ACE); + HandOfCards curHand = new HandOfCards(); + curHand.addCard(pc); + curHand.addCard(pc1); + curHand.addCard(pc2); + curHand.addCard(pc3); + // When + int actual = curHand.howManyOfValue(PlayingCardValue.ACE); + // Then + assertEquals(expected, actual); + } + + @Test + public void containsSuitTest1() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + PlayingCard pc3 = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.ACE); + HandOfCards curHand = new HandOfCards(); + curHand.addCard(pc); + curHand.addCard(pc3); + // When + boolean actual = curHand.containsSuit(PlayingCardSuit.DIAMONDS); + // Then + assertEquals(true, actual); + } + @Test + public void containsSuitTest2() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + PlayingCard pc3 = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.ACE); + HandOfCards curHand = new HandOfCards(); + curHand.addCard(pc); + curHand.addCard(pc3); + // When + boolean actual = curHand.containsSuit(PlayingCardSuit.HEARTS); + // Then + assertEquals(false, actual); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardTest.java b/src/test/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardTest.java new file mode 100644 index 00000000..8d61b9d2 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/cardutils/PlayingCardTest.java @@ -0,0 +1,156 @@ +package com.github.zipcodewilmington.casino.cardutils; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class PlayingCardTest { + @Test + public void constructorTest() { + // Given + PlayingCardSuit expectedSuit = PlayingCardSuit.HEARTS; + PlayingCardValue expectedValue = PlayingCardValue.FIVE; + // When + PlayingCard pc = new PlayingCard(expectedSuit, expectedValue); + // When + PlayingCardSuit actualSuit = pc.getSuit(); + PlayingCardValue actualValue = pc.getValue(); + // Then + assertEquals(expectedValue, actualValue); + assertEquals(expectedSuit, actualSuit); + } + + @Test + public void getSuitTest() { + // Given + PlayingCardSuit expectedSuit = PlayingCardSuit.HEARTS; + // When + PlayingCard pc = new PlayingCard(expectedSuit, PlayingCardValue.ACE); + // When + PlayingCardSuit actualSuit = pc.getSuit(); + // Then + assertEquals(expectedSuit, actualSuit); + } + + @Test + public void getValueTest() { + // Given + PlayingCardValue expectedValue = PlayingCardValue.FIVE; + // When + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, expectedValue); + // When + PlayingCardValue actualValue = pc.getValue(); + // Then + assertEquals(expectedValue, actualValue); + } + + @Test + public void compareValueTest1() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.FIVE); + PlayingCard otherCard = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.FIVE); + // When + int actual = pc.compareValue(otherCard); + // Then + assertEquals(true, actual == 0); // should be equal + } + @Test + public void compareValueTest2() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.THREE); + PlayingCard otherCard = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.FIVE); + // When + int actual = pc.compareValue(otherCard); + // Then + assertEquals(true, actual < 0); // should be less than 0 + } + @Test + public void compareValueTest3() { + // Given + int expected = 1; + PlayingCard pc = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.FIVE); + PlayingCard otherCard = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.THREE); + // When + int actual = pc.compareValue(otherCard); + // Then + assertEquals(true, actual > 0); // should be greater than 0 + } + + @Test + public void toStringTest1() { + // Given + String expected = "5 of Diamonds"; + PlayingCard pc = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.FIVE); + // When + String actual = pc.toString(); + // Then + assertEquals(expected, actual); // should be equal + } + @Test + public void toStringTest2() { + // Given + String expected = "A of Spades"; + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE); + // When + String actual = pc.toString(); + // Then + assertEquals(expected, actual); // should be equal + } + @Test + public void toStringTest3() { + // Given + String expected = "J of Clubs"; + PlayingCard pc = new PlayingCard(PlayingCardSuit.CLUBS, PlayingCardValue.JACK); + // When + String actual = pc.toString(); + // Then + assertEquals(expected, actual); // should be equal + } + @Test + public void toStringTest4() { + // Given + String expected = "K of Hearts"; + PlayingCard pc = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.KING); + // When + String actual = pc.toString(); + // Then + assertEquals(expected, actual); // should be equal + } + + @Test + public void equalsTest1() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.FIVE); + PlayingCard otherCard = new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.FIVE); + // When + boolean regularEquals = pc == otherCard; + boolean dotEquals = pc.equals(otherCard); + // Then: Cards are not equal + assertEquals(false, regularEquals); + assertEquals(false, dotEquals); + } + @Test + public void equalsTest2() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.FIVE); + PlayingCard otherCard = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.FIVE); + // When + boolean regularEquals = pc == otherCard; + boolean dotEquals = pc.equals(otherCard); + // Then: Cards ARE equal + assertEquals(false, regularEquals); + assertEquals(true, dotEquals); + } + @Test + public void equalsTest3() { + // Given + PlayingCard pc = new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.FIVE); + PlayingCard otherCard = new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.FIVE); + // When + boolean regularEquals = pc == otherCard; + boolean dotEquals = pc.equals(otherCard); + // Then: Cards are not equal + assertEquals(false, regularEquals); + assertEquals(false, dotEquals); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/cardutils/TheDeckTest.java b/src/test/java/com/github/zipcodewilmington/casino/cardutils/TheDeckTest.java new file mode 100644 index 00000000..68509a13 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/cardutils/TheDeckTest.java @@ -0,0 +1,129 @@ +package com.github.zipcodewilmington.casino.cardutils; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.HashSet; + +import static org.junit.Assert.*; + +public class TheDeckTest { + @Test + public void reclaimCardsTest1() { + //Given + TheDeck theDeck = new TheDeck(); + PlayingCard[] initialDeck = theDeck.getDeck(); + //When + theDeck.drawCard(); + theDeck.reclaimCards(); + //When + PlayingCard[] actualDeck = theDeck.getDeck(); + //Then + assertEquals(true, Arrays.equals(initialDeck, actualDeck)); + } + @Test + public void reclaimCardsTest2() { + //Given + int expected = 52; + TheDeck theDeck = new TheDeck(); + //When + theDeck.drawCard(); + theDeck.reclaimCards(); + //When + PlayingCard[] actualDeck = theDeck.getDeck(); + //Then + assertEquals(expected, actualDeck.length); + } + + @Test + public void shuffleTest1() { + //Given + TheDeck theDeck = new TheDeck(); + PlayingCard[] initialDeck = theDeck.getDeck(); + //When + theDeck.shuffle(); + //When + PlayingCard[] actualDeck = theDeck.getDeck(); + //Then: the two arrays aren't equal because their orders are different + assertEquals(false, Arrays.equals(initialDeck, actualDeck)); + } + @Test + public void shuffleTest2() { + //Given + TheDeck actualDeck = new TheDeck(); + PlayingCard[] initialDeck = actualDeck.getDeck(); + //When + actualDeck.shuffle(); + //Then: the stack contains all the elements in the initial deck array + assertEquals(true, actualDeck.containsAll(Arrays.asList(initialDeck))); + } + @Test + public void shuffleTest3() { + //Given + TheDeck theDeck = new TheDeck(); + TheDeck secondDeck = new TheDeck(); + //When + theDeck.shuffle(); + secondDeck.shuffle(); + //When + PlayingCard[] initialDeck = theDeck.getDeck(); + PlayingCard[] otherDeck = secondDeck.getDeck(); + //Then: two decks shuffle differently + assertEquals(false, Arrays.equals(initialDeck, otherDeck)); + } + + @Test + public void drawCardTest() { + //Given + int expectedSize = 51; + TheDeck theDeck = new TheDeck(); + //When + theDeck.drawCard(); + PlayingCard[] actualArray = theDeck.getDeck(); + //Then + assertEquals(expectedSize, actualArray.length); + } + + @Test + public void hasCardsLeftTest1() { + //Given + TheDeck theDeck = new TheDeck(); + //When + boolean actual = theDeck.hasCardsLeft(); + //Then + assertEquals(true, actual); + } + @Test + public void hasCardsTest2() { + //Given + TheDeck theDeck = new TheDeck(); + for(int i = 0; i < 52; i++){ + theDeck.drawCard(); + } + //When + boolean actual = theDeck.hasCardsLeft(); + //Then + assertEquals(false, actual); + } + + @Test + public void constructorTest1() { + //Given + int expectedSize = 52; + TheDeck theDeck = new TheDeck(); + //When + PlayingCard[] actualDeck = theDeck.getDeck(); + //Then + assertEquals(expectedSize, actualDeck.length); + } + @Test + public void constructorTest2() { + //Given + int expectedSize = 52; + TheDeck theDeck = new TheDeck(); + //When + HashSet initialSet = new HashSet<>(theDeck); + //Then + assertEquals(expectedSize, initialSet.size()); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGameTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGameTest.java new file mode 100644 index 00000000..5ee3cb92 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackGameTest.java @@ -0,0 +1,67 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import com.github.zipcodewilmington.casino.cardutils.HandOfCards; +import com.github.zipcodewilmington.casino.cardutils.PlayingCard; +import com.github.zipcodewilmington.casino.cardutils.PlayingCardSuit; +import com.github.zipcodewilmington.casino.cardutils.PlayingCardValue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class BlackJackGameTest { + @Test + void payOutCalcTest() { + // Given + int expected = 14; + BlackJackGame blackjack = new BlackJackGame(); + // When + int actual = blackjack.payOutCalc(expected); + // Then + assertEquals(expected * 2, actual); + } + +// @Test +// void beatDealerTest() { +// // Given +// int dealerHand = 12; +// int yourHand = 20; +// BlackJackGame blackjack = new BlackJackGame(); +// // When +// boolean actual = blackjack.beatDealer(dealerHand > 21, dealerHand, yourHand); +// // Then +// assertEquals(true, actual); +// } +// @Test +// void beatDealerTest1() { +// // Given +// int dealerHand = 22; +// int yourHand = 20; +// BlackJackGame blackjack = new BlackJackGame(); +// // When +// boolean actual = blackjack.beatDealer(dealerHand, yourHand); +// // Then +// assertEquals(true, actual); +// } +// @Test +// void beatDealerTest2() { +// // Given +// int dealerHand = 12; +// int yourHand = 1; +// BlackJackGame blackjack = new BlackJackGame(); +// // When +// boolean actual = blackjack.beatDealer(dealerHand, yourHand); +// // Then +// assertEquals(false, actual); +// } +// @Test +// void beatDealerTest3() { +// // Given +// int dealerHand = 1; +// int yourHand = 22; +// BlackJackGame blackjack = new BlackJackGame(); +// // When +// boolean actual = blackjack.beatDealer(dealerHand, yourHand); +// // Then +// assertEquals(false, actual); +// } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackPlayerTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackPlayerTest.java new file mode 100644 index 00000000..7d041ebe --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/BlackJackPlayerTest.java @@ -0,0 +1,79 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import com.github.zipcodewilmington.casino.cardutils.HandOfCards; +import com.github.zipcodewilmington.casino.cardutils.PlayingCard; +import com.github.zipcodewilmington.casino.cardutils.PlayingCardSuit; +import com.github.zipcodewilmington.casino.cardutils.PlayingCardValue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class BlackJackPlayerTest { + + @Test + void isStayOrNot() { + } + + @Test + void play() { + } + + @Test + void makeBet() { + } + + @Test + void validBet() { + } + + @Test + void depositPayOut() { + } + + @Test + void hitMe() { + } + + @Test + void stay() { + } + + @Test + void calculateScoreTest() { + // Given + int expected = 12; + HandOfCards curHand = new HandOfCards(); + curHand.addCard(new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE)); + curHand.addCard(new PlayingCard(PlayingCardSuit.DIAMONDS, PlayingCardValue.ACE)); + // When + int actual = new BlackJackPlayer(curHand).calculateScore(); + // Then + assertEquals(expected, actual); + } + @Test + void calculateScoreTest1() { + // Given + int expected = 21; + HandOfCards curHand = new HandOfCards(); + curHand.addCard(new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.ACE)); + curHand.addCard(new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.KING)); + curHand.addCard(new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.QUEEN)); + // When + int actual = new BlackJackPlayer(curHand).calculateScore(); + // Then + assertEquals(expected, actual); + } + @Test + void calculateScoreTest2() { + // Given + int expected = 20; + HandOfCards curHand = new HandOfCards(); + curHand.addCard(new PlayingCard(PlayingCardSuit.SPADES, PlayingCardValue.FIVE)); + curHand.addCard(new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.FIVE)); + curHand.addCard(new PlayingCard(PlayingCardSuit.HEARTS, PlayingCardValue.JACK)); + // When + int actual = new BlackJackPlayer(curHand).calculateScore(); + // Then + assertEquals(expected, actual); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/DealerPlayerTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/DealerPlayerTest.java new file mode 100644 index 00000000..2b08b554 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/blackjack/DealerPlayerTest.java @@ -0,0 +1,20 @@ +package com.github.zipcodewilmington.casino.games.blackjack; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DealerPlayerTest { + + @Test + void isShowFirstCard() { + } + + @Test + void play() { + } + + @Test + void printHand() { + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGameTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGameTest.java new file mode 100644 index 00000000..6c4af2df --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessGameTest.java @@ -0,0 +1,37 @@ +package com.github.zipcodewilmington.casino.games.numberguess; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class NumberGuessGameTest { + + @Test + void randomNum() { + //Given + + //When + //Then + } + + @Test + void makeGuess() { + //Given + //When + //Then + } + + @Test + void validateGuess() { + //Given + //When + //Then + } + + @Test + void getRemainingGuesses() { + //Given + //When + //Then + } +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayerTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayerTest.java new file mode 100644 index 00000000..affea0ef --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/numberguess/NumberGuessPlayerTest.java @@ -0,0 +1,83 @@ +package com.github.zipcodewilmington.casino.games.numberguess; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class NumberGuessPlayerTest { + + @Test + void incrementScoreTest() { + //Given + NumberGuessPlayer player = new NumberGuessPlayer(null, null); + player.incrementScore(); + player.incrementScore(); + player.incrementScore(); + player.incrementScore(); + player.incrementScore(); + + //When + int expected = player.getScore(); + int actual = 5; + + //Then + Assert.assertEquals(expected, actual); + + } + + @Test + void setPlayerScore() { + //Given + NumberGuessPlayer player = new NumberGuessPlayer(null, null); + player.setPlayerScore(76); + //When + int expected = player.getScore(); + int actual = 76; + //Then + Assert.assertEquals(expected, actual); + } + + @Test + void getScoreTest() { + //Given + NumberGuessPlayer player = new NumberGuessPlayer(null, null); + + //When + int expected = player.getScore(); + int actual = 0; + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + void calcWinRateTest() { + //Given + NumberGuessPlayer player = new NumberGuessPlayer(null, null); + player.setPlayerScore(34); + + //When + double expected = player.calcWinRate(100); + double actual = 34.00; + + //Then + Assert.assertEquals(expected, actual, 0); + } + + @Test + void updateGameTest() { + //Given + NumberGuessPlayer player = new NumberGuessPlayer(null, null); + player.setTotalGames(5); + //When + player.updateGame(true); + int expected = 6; + int actual = player.getTotalGames(); + //Then + Assert.assertEquals(expected, actual); + } + + +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGamePlayerTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGamePlayerTest.java new file mode 100644 index 00000000..0088ce73 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGamePlayerTest.java @@ -0,0 +1,41 @@ +package com.github.zipcodewilmington.casino.games.slots; + +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.utils.IOConsole; +import org.junit.Assert; +import org.junit.Test; + +public class SlotsGamePlayerTest { + + @Test + public void testMakeBet() { + CasinoAccount wallet = new CasinoAccount("Brent", 500); + IOConsole console = new IOConsole(); + SlotsPlayer.SlotsPlayer brent = new SlotsPlayer.SlotsPlayer(wallet,console); + Integer expected = 1000; + Integer actual = brent.makeBet(expected); + Assert.assertEquals(expected,actual); + + } + + @Test + public void testValidBet () { + CasinoAccount wallet = new CasinoAccount("Brent", 1000); + IOConsole console = new IOConsole(); + SlotsPlayer brent = new SlotsPlayer(wallet,console); + Integer expected = 1000; + Integer actual = brent.getWallet(); + Assert.assertEquals(expected,actual); + + } + + // need help!!! + @Test + public void testDepositPayOut() { + CasinoAccount wallet = new CasinoAccount("Brent", 1000); + IOConsole console = new IOConsole(); + SlotsPlayer brent = new SlotsPlayer(wallet,console); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGameTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGameTest.java new file mode 100644 index 00000000..b2153749 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGameTest.java @@ -0,0 +1,7 @@ +package com.github.zipcodewilmington.casino.games.slots; + +import static org.junit.jupiter.api.Assertions.*; + +class SlotsGameTest { + +} \ No newline at end of file