diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..a0883d30 Binary files /dev/null and b/.DS_Store differ diff --git a/savedAccounts.txt b/savedAccounts.txt new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/savedAccounts.txt @@ -0,0 +1 @@ +test diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 00000000..0b0b5aec 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..571cf100 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..81e425f5 Binary files /dev/null and b/src/main/java/.DS_Store differ diff --git a/src/main/java/com/.DS_Store b/src/main/java/com/.DS_Store new file mode 100644 index 00000000..7ef0c568 Binary files /dev/null and b/src/main/java/com/.DS_Store differ diff --git a/src/main/java/com/github/.DS_Store b/src/main/java/com/github/.DS_Store new file mode 100644 index 00000000..aaa33cfe Binary files /dev/null and b/src/main/java/com/github/.DS_Store differ diff --git a/src/main/java/com/github/zipcodewilmington/.DS_Store b/src/main/java/com/github/zipcodewilmington/.DS_Store new file mode 100644 index 00000000..b68fbe6f Binary files /dev/null and b/src/main/java/com/github/zipcodewilmington/.DS_Store differ diff --git a/src/main/java/com/github/zipcodewilmington/Casino.java b/src/main/java/com/github/zipcodewilmington/Casino.java index 5eae9ac0..918255ab 100644 --- a/src/main/java/com/github/zipcodewilmington/Casino.java +++ b/src/main/java/com/github/zipcodewilmington/Casino.java @@ -4,6 +4,10 @@ import com.github.zipcodewilmington.casino.CasinoAccountManager; import com.github.zipcodewilmington.casino.GameInterface; import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.games.chuckaluck.ChuckALuckGame; +import com.github.zipcodewilmington.casino.games.chuckaluck.ChuckALuckPlayer; +import com.github.zipcodewilmington.casino.games.connectfour.ConnectFour; +import com.github.zipcodewilmington.casino.games.connectfour.ConnectFourPlayer; import com.github.zipcodewilmington.casino.games.numberguess.NumberGuessGame; import com.github.zipcodewilmington.casino.games.numberguess.NumberGuessPlayer; import com.github.zipcodewilmington.casino.games.slots.SlotsGame; @@ -11,6 +15,8 @@ import com.github.zipcodewilmington.utils.AnsiColor; import com.github.zipcodewilmington.utils.IOConsole; +import java.util.Objects; + /** * Created by leon on 7/21/2020. */ @@ -21,44 +27,70 @@ public class Casino implements Runnable { public void run() { String arcadeDashBoardInput; CasinoAccountManager casinoAccountManager = new CasinoAccountManager(); + try{ do { arcadeDashBoardInput = getArcadeDashboardInput(); - if ("select-game".equals(arcadeDashBoardInput)) { - String accountName = console.getStringInput("Enter your account name:"); - String accountPassword = console.getStringInput("Enter your account password:"); - CasinoAccount casinoAccount = casinoAccountManager.getAccount(accountName, accountPassword); - boolean isValidLogin = casinoAccount != null; - if (isValidLogin) { - String gameSelectionInput = getGameSelectionInput().toUpperCase(); - if (gameSelectionInput.equals("SLOTS")) { - play(new SlotsGame(), new SlotsPlayer()); - } else if (gameSelectionInput.equals("NUMBERGUESS")) { - play(new NumberGuessGame(), new NumberGuessPlayer()); + + if ("2".equals(arcadeDashBoardInput)) { //log-in + + String accountName = console.getStringInput("Enter your account name:"); + String accountPassword = console.getStringInput("Enter your account password:"); + CasinoAccount casinoAccount = casinoAccountManager.getAccount(accountName, accountPassword); + boolean isValidLogin = casinoAccount != null; + if (isValidLogin) { + displayGameMenu(); + + } else { // TODO - implement better exception handling - String errorMessage = "[ %s ] is an invalid game selection"; - throw new RuntimeException(String.format(errorMessage, gameSelectionInput)); + String errorMessage = "No account found with name of [ %s ] and password of [ %s ]"; + throw new RuntimeException(String.format(errorMessage, accountName, accountPassword)); } - } else { - // TODO - implement better exception handling - String errorMessage = "No account found with name of [ %s ] and password of [ %s ]"; - throw new RuntimeException(String.format(errorMessage, accountPassword, accountName)); - } - } else if ("create-account".equals(arcadeDashBoardInput)) { - console.println("Welcome to the account-creation screen."); - String accountName = console.getStringInput("Enter your account name:"); - String accountPassword = console.getStringInput("Enter your account password:"); - CasinoAccount newAccount = casinoAccountManager.createAccount(accountName, accountPassword); - casinoAccountManager.registerAccount(newAccount); - } - } while (!"logout".equals(arcadeDashBoardInput)); + + + + } else if ("1".equals(arcadeDashBoardInput)) { //create-account + console.println("Welcome to the account-creation screen."); + String accountName = console.getStringInput("Enter your account name:"); + String accountPassword = console.getStringInput("Enter your account password:"); + CasinoAccount newAccount = casinoAccountManager.createAccount(accountName, accountPassword); + casinoAccountManager.registerAccount(newAccount); + displayGameMenu(); + } + + } while(!"logout".equals(arcadeDashBoardInput)); + } catch (RuntimeException e){ + System.out.println(e.getMessage()); + } +} + + private void displayGameMenu(){ + String gameSelectionInput = getGameSelectionInput().toUpperCase(); + if (gameSelectionInput.equals("1")) { //slots + play(new SlotsGame(), new SlotsPlayer()); +// } else if (gameSelectionInput.equals("2")) { //cee-lo +// play(new CeeloGame(), new CeeloPlayer()); + } else if (gameSelectionInput.equals("3")) { //chuck a luck + play(new ChuckALuckGame(), new ChuckALuckPlayer()); + } else if (gameSelectionInput.equals("4")) { //connect four + play(new ConnectFour(), new ConnectFourPlayer()); +// } else if (gameSelectionInput.equals("5")) { //blackjack +// play(new BlackjackGame(), new BlackjackPlayer()); +// }else if (gameSelectionInput.equals("6")) { //war +// play(new WarGame(), new WarPlayer()); + } else { + // TODO - implement better exception handling + String errorMessage = "[ %s ] is an invalid game selection"; + throw new RuntimeException(String.format(errorMessage, gameSelectionInput)); + } } + private String getArcadeDashboardInput() { return console.getStringInput(new StringBuilder() .append("Welcome to the Arcade Dashboard!") .append("\nFrom here, you can select any of the following options:") - .append("\n\t[ create-account ], [ select-game ]") + .append("\n\t[ 1. create-account ], [ 2. log-in ]") .toString()); } @@ -66,13 +98,13 @@ private String getGameSelectionInput() { return console.getStringInput(new StringBuilder() .append("Welcome to the Game Selection Dashboard!") .append("\nFrom here, you can select any of the following options:") - .append("\n\t[ SLOTS ], [ NUMBERGUESS ]") + .append("\n\t[ 1. SLOTS ], [ 2. CEE-LO ], [ 3. CHUCK A LUCK], [ 4. CONNECT 4 ], [ 5. BLACKJACK ], [ 6. WAR ]") .toString()); } private void play(Object gameObject, Object playerObject) { - GameInterface game = (GameInterface)gameObject; - PlayerInterface player = (PlayerInterface)playerObject; + GameInterface game = (GameInterface) gameObject; + PlayerInterface player = (PlayerInterface) playerObject; game.add(player); game.run(); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/ArcadeAccount.java b/src/main/java/com/github/zipcodewilmington/casino/ArcadeAccount.java new file mode 100644 index 00000000..c693fc6e --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/ArcadeAccount.java @@ -0,0 +1,2 @@ +package com.github.zipcodewilmington.casino.games;public class ArcadeAccount { +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java index 654c749b..daca7a9c 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccount.java @@ -6,4 +6,35 @@ * The `ArcadeAccount` is used to log into the system to select a `Game` to play. */ public class CasinoAccount { + + String userName; + String password; + Integer accountBalance; + + public CasinoAccount(String userName, String password) { + this.userName = userName; + this.password = password; + } + + public CasinoAccount(String userName, String password, Integer balance) { + this.userName = userName; + this.password = password; + this.accountBalance = balance; + } + public void updateAccountBalance(Integer amount) { + this.accountBalance += amount; + } + + public String getUserName() { + return userName; + } + + public String getPassword() { + return password; + } + + public Integer getAccountBalance() { + return accountBalance; + } + } diff --git a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java index 2d09ec2a..9d5ca583 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java +++ b/src/main/java/com/github/zipcodewilmington/casino/CasinoAccountManager.java @@ -1,23 +1,37 @@ package com.github.zipcodewilmington.casino; +import java.util.*; + /** * 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 { + + private List accountList = new ArrayList<>(); /** * @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)); + + for (CasinoAccount a : accountList) { + if (accountName.equals(a.getUserName()) && accountPassword.equals(a.getPassword())) { + return a; + } + } + +// 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)); + return null; } +// if (accountManager.getAccount(param1, parfam2) == null) {sysmt.out.pronta;ksdjhfa;ls} + /** * logs & creates a new `ArcadeAccount` * @@ -26,10 +40,14 @@ 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)); + + CasinoAccount newAccount = new CasinoAccount(accountName, accountPassword); + return newAccount; + +// 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)); } /** @@ -38,9 +56,11 @@ 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)); + + this.accountList.add(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)); } } diff --git a/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java b/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java index c50b5113..77cf314f 100644 --- a/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java +++ b/src/main/java/com/github/zipcodewilmington/casino/PlayerInterface.java @@ -10,12 +10,12 @@ 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(); + // SomeReturnType play(); } diff --git a/src/main/java/com/github/zipcodewilmington/casino/blackjack/BlackJackGame.java b/src/main/java/com/github/zipcodewilmington/casino/blackjack/BlackJackGame.java new file mode 100644 index 00000000..e6da3a21 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/blackjack/BlackJackGame.java @@ -0,0 +1,177 @@ +package com.github.zipcodewilmington.casino.blackjack; + +import java.util.InputMismatchException; +import java.util.Scanner; +import java.util.Random; + + + +public class BlackJackGame { + int playerHand = 0; + int dealerHand = 0; + + int playerChips = 500; + + int playerBet = 0; + + public static void main(String[] args) { + System.out.println("Welcome to the Bobby's Brutal Blackjack. Name's Bobby, nice to meet cha."); + BlackJackGame bj = new BlackJackGame(); + bj.playGame(); + } + + + void playGame() { +Scanner scan = new Scanner(System.in); + + welcomeStatement(); + showPlayerBet(); + showDealerHand1(); + dealerRecap1(); + playerRecap(); + scan.nextLine(); + showPlayerDraw(); + showDealerHand2(); + dealerRecap2(); + while (playerHand < 21 && playerHand <= dealerHand) { + if ((playerChips - playerBet) > playerBet) { + System.out.println("Right now you got " + playerHand + ". Type 'dd' to double down, or hit enter to draw"); + String respond = scan.nextLine(); + if (respond.equals("dd")) { + doubleDown(); + } else { + showPlayerDraw(); + } + }else{ + playerRecap(); + scan.nextLine(); + showPlayerDraw(); + } + } + + if (playerHand <= 21 && playerHand > dealerHand){ + playerWins(); + } else if (playerHand > 21){ + dealerWins(); + } + + } + + + + private void welcomeStatement(){ + System.out.println("Let's jack it up!\n"); + } + + private int showDealerHand1(){ + dealerHand = 10; + return dealerHand; + } + + private int showDealerHand2(){ + Random random = new Random(); + int min = 6; + int max = 4; + dealerHand += min + random.nextInt(max); + return dealerHand; + } + + public void dealerRecap1() { + System.out.println("It looks like the dealer has pulled a " + dealerHand + "."); + } + public void dealerRecap2() { + System.out.println("It looks like the dealer has pulled a " + dealerHand + ". See if you can beat that."); + } + + public void playerRecap(){ + System.out.println("Right now you got " + playerHand + ". Hit enter to draw"); + } + + private int showPlayerBet(){ + Scanner scan = new Scanner(System.in); + System.out.println("How many chips are ya bettin'?"); + try { + playerBet = scan.nextInt(); + } catch (InputMismatchException e) { + System.out.println("That ain't a number I ever heard of."); + showPlayerBet(); + } + if (playerBet > playerChips){ + System.out.println("That bet is too big for your britches. Try a smaller amount."); + showPlayerBet(); + }else if (playerBet < 0) { + System.out.println("Hey, don't try it with the funny business!"); + showPlayerBet(); + } + return playerBet; + } + + + private int showPlayerDraw() { + Random random = new Random(); + Scanner scan = new Scanner(System.in); + int min = 1; + int nextDraw = min + random.nextInt(9); + if (nextDraw == 1 || nextDraw == 11){ + aces(); + } else{ + playerHand += nextDraw; + System.out.println("Ya drew a " + nextDraw + "!"); + } + return playerHand; + } + + + private int aces() { + int nextDraw = 0; + Scanner scan = new Scanner(System.in); + System.out.println("Ooh, an Ace! Choose if you want this Ace to be a 1 or an 11."); + try {nextDraw = scan.nextInt(); + } catch (InputMismatchException e) { + System.out.println("That ain't a number I ever heard of."); + aces(); + } + if (nextDraw == 1 || nextDraw == 11) { + playerHand += nextDraw; + System.out.println("Ya drew a " + nextDraw + "!"); + }else{ + System.out.println("Nice try."); + aces(); + } + return playerHand; + } + + + + public void playerWins(){ + Scanner scan = new Scanner(System.in); + playerChips += playerBet; + System.out.println("Woah! You got " + playerHand + " and won " + playerBet + " chips! You now have " + playerChips + " chips! Hit enter to try again."); + playerHand = 0; + scan.nextLine(); + playGame(); + } + + public void dealerWins(){ + Scanner scan = new Scanner(System.in); + playerChips-=playerBet; + System.out.println(playerHand + "! Welp, them's the breaks, kid. You lost " + playerBet + " chips and now have " + playerChips + " chips. Hit enter to play again."); + playerHand = 0; + scan.nextLine(); + playGame(); + } + + public void doubleDown(){ + playerBet = playerBet * 2; + System.out.println("OK kid, this next one is for all da marbles! Let's see what cha got!"); + showPlayerDraw(); + if (playerHand <= 21 && playerHand > dealerHand){ + playerWins(); + } else{ + dealerWins(); + } + } + + } + + diff --git a/src/main/java/com/github/zipcodewilmington/casino/blackjack/BlackJackPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/blackjack/BlackJackPlayer.java new file mode 100644 index 00000000..4d0bdc2e --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/blackjack/BlackJackPlayer.java @@ -0,0 +1,4 @@ +package com.github.zipcodewilmington.casino.blackjack; + +public class BlackJackPlayer { +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Card.java b/src/main/java/com/github/zipcodewilmington/casino/games/Card.java new file mode 100644 index 00000000..141bbc7d --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Card.java @@ -0,0 +1,81 @@ +package com.github.zipcodewilmington.casino.games; + +import com.sun.security.jgss.InquireSecContextPermission; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Card { + private String faceName, suit; + private int value; + + public String getFaceName() { + return faceName; + } + + public static List getValidFaceNames(){ + return Arrays.asList("2","3","4","5","6","7","8","9","10", + "jack","queen","king","ace"); + } + + public void setFaceName(String faceName) { + List validFaceNames = getValidFaceNames(); + faceName = faceName.toLowerCase(); + if (validFaceNames.contains(faceName)){ + this.faceName = faceName;} + else + throw new IllegalArgumentException("Valid face names are: " + validFaceNames); + } + + public String getSuit() { + return suit; + } + + public static List getValidSuits(){ + return Arrays.asList("hearts", "diamonds", "spades", "clubs"); + } + + public void setSuit(String suit) { + List validSuits = getValidSuits(); + suit = suit.toLowerCase(); + + if (validSuits.contains(suit)) { + this.suit = suit; + } + else + throw new IllegalArgumentException("valid suits are: " + validSuits); + } + + public String toString(){ + return String.format("%s of %s", faceName, suit); + } + + public int getValue(){ + return value; + } + + public static List getValidValues(){ + if (DeckOfCards.blackJackTrueWarFalse == true){ + return Arrays.asList(2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11); + } + else{ + return Arrays.asList(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); + } + } + + public void setValue(int value){ + if(value > 0 && value < 15) { + this.value = value; + } + else{ + throw new IllegalArgumentException("Valid value is 1 to 14" ); + } + } + + public Card(String faceName, String suit, Integer value) { + setFaceName(faceName); + setSuit(suit); + setValue(value); + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/DeckOfCards.java b/src/main/java/com/github/zipcodewilmington/casino/games/DeckOfCards.java new file mode 100644 index 00000000..f4f69ee9 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/DeckOfCards.java @@ -0,0 +1,60 @@ +package com.github.zipcodewilmington.casino.games; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class DeckOfCards { + private ArrayList deck; + private Card drawnCard; + public static boolean blackJackTrueWarFalse; + + public DeckOfCards(ArrayList deck) { + this.deck = deck; + } + + public ArrayList getDeck() { + return deck; + } + + public void setDeck(ArrayList deck) { + this.deck = deck; + } + + public ArrayList shuffle(){ + Collections.shuffle(deck); + return deck; + } + + public int size(){ + return deck.size(); + } + + public Card get(int i){ + return deck.get(i); + } + + public Card draw(){ + drawnCard = deck.get(0); + deck.remove(0); + return drawnCard; + } + + public DeckOfCards(){ + List suits = Card.getValidSuits(); + List faceNames = Card.getValidFaceNames(); + List values = Card.getValidValues(); + + deck = new ArrayList<>(); + int i; + for (String suit: suits){ + i = 0; + for (String faceName: faceNames){ + deck.add(new Card(faceName, suit, values.get(i))); +// System.out.println(deck.size()+". "+faceName+" of "+suit+" value:"+values.get(i)); + i++; + } + } + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Dice.java b/src/main/java/com/github/zipcodewilmington/casino/games/Dice.java new file mode 100644 index 00000000..e961e06d --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Dice.java @@ -0,0 +1,46 @@ +package com.github.zipcodewilmington.casino.games; + +import java.util.ArrayList; +import java.util.List; + +public class Dice { + static List bins; + private Integer numOfDice; + private Integer maxRoll; + + public Dice(Integer numOfDice) { + this.numOfDice = numOfDice; + this.maxRoll = numOfDice * 6; + } + + public Integer tossAndSum(){ + + // Roll n amount of times and return the sum of the rolls. + + int result = 0; + for (int i = 0; i < numOfDice; i++) { + result += (6 * Math.random() + 1); + } + return result; + } + + // create an ArrayList populated with 0's. Number of elements depends on number of dice. + + public void initializeBins() { + bins = new ArrayList(); + for (int i = numOfDice; i < (maxRoll + numOfDice); i++){ + bins.add(0); + } + } + + //return bin for a specified value + + public Integer getBin(Integer number){ + return bins.get(number); + } + + public void incrementBin(int sum) { + bins.set(sum, getBin(sum)+1); + } + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/Player.java b/src/main/java/com/github/zipcodewilmington/casino/games/Player.java new file mode 100644 index 00000000..4e1dfd07 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/Player.java @@ -0,0 +1,27 @@ +package com.github.zipcodewilmington.casino.games; + +import com.github.zipcodewilmington.casino.CasinoAccount; + +public class Player { + public String name; + public static int balance; + CasinoAccount casinoAccount; + + public Player(String name){ + this.name=name; + } + + public Player(){} + + public String getName(){ + return this.name; + } + + public static int getBalance(){ + return balance; + } + + public void setBalance(int balance){ + Player.balance = balance; + } +} 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..74a79d18 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/blackjack/BlackjackGame.java @@ -0,0 +1,122 @@ +package com.github.zipcodewilmington.casino.games.blackjack; +import java.sql.SQLOutput; +import java.util.InputMismatchException; +import java.util.Scanner; +import java.util.Random; + + + +public class BlackjackGame { +int playerAmount = 0; +int dealerAmount = 0; + +int playerChips = 5; + +int playerBet = 0; + + public static void main(String[] args) { + System.out.println("Welcome to the Bobby's Brutal Blackjack. Name's Bobby, nice to meet cha."); + BlackjackGame bj = new BlackjackGame(); + bj.playGame(); + } + + +void playGame() { + getDealerAmount(); + welcomeStatement(); + getPlayerBet(); + dealerRecap(); + +while (playerAmount < 21 && playerAmount <= dealerAmount){ + playerDraw(); + +} + +if (playerAmount <= 21 && playerAmount > dealerAmount){ + playerWins(); +} else if (playerAmount > 21){ + dealerWins(); +} + +} + + + +private void welcomeStatement(){ + System.out.println("Let's jack it up!.\n"); +} + +public int getDealerAmount(){ + Random random = new Random(); + int min = 17; + int max = 3; + int dealerNum = min + random.nextInt(max); + dealerAmount = dealerNum; + return dealerAmount; +} + + public void dealerRecap() { + System.out.println("It looks like the dealer has pulled a " + dealerAmount + ". See if you can beat that."); + } + + public int playerDraw() { + Random random = new Random(); + Scanner scan = new Scanner(System.in); + int min = 1; + System.out.println("OK kid, you got " + playerAmount + ". Draw a card and see if you can win."); + System.out.println("Hit enter to draw"); + scan.nextLine(); + int nextDraw = min + random.nextInt(9); + playerAmount += nextDraw; + return playerAmount; + + + } + + public void playerWins(){ + Scanner scan = new Scanner(System.in); + playerChips += playerBet; + System.out.println("Wowzers, you got " + playerAmount + " and won " + playerBet + " chips! You now have " + playerChips + " chips!"); + playerAmount = 0; + scan.nextLine(); + playGame(); + } + + public void dealerWins(){ + Scanner scan = new Scanner(System.in); + playerChips-=playerBet; + System.out.println(playerAmount + "! Welp, them's the breaks, kid. You lost " + playerBet + " chips and now have " + playerChips + " chips."); + playerAmount = 0; + scan.nextLine(); + playGame(); + } + + + + public int getPlayerBet(){ + Scanner scan = new Scanner(System.in); + System.out.println("How many chips are ya bettin'? 0 is also an option."); + playerBet = scan.nextInt(); + if (playerBet > playerChips){ + System.out.println("Kid, that bet is too big for your britches. Try a smaller amount."); + getPlayerBet(); + }else if (playerBet < 0) { + System.out.println("Hey, don't try it with the funny business!"); + getPlayerBet(); + } + return playerBet; + } + +// int getNumb(String message) { +// +// Scanner scan = new Scanner(System.in); +// while (true) { +// System.out.print(message); +// try { +// return scan.nextInt(); +// } +// catch (InputMismatchException e) { +// System.out.println("\"" + scan.next() + "\" isn't a number!"); + + } + diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckGame.java b/src/main/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckGame.java new file mode 100644 index 00000000..009c5988 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckGame.java @@ -0,0 +1,186 @@ +package com.github.zipcodewilmington.casino.games.chuckaluck; + +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.games.Dice; +import com.github.zipcodewilmington.casino.games.Player; +import com.github.zipcodewilmington.utils.AnsiColor; +import com.github.zipcodewilmington.utils.IOConsole; + +public class ChuckALuckGame implements GameInterface { + private final IOConsole Red = new IOConsole(AnsiColor.RED); + private final IOConsole Green = new IOConsole(AnsiColor.GREEN); + private final IOConsole Yellow = new IOConsole(AnsiColor.YELLOW); + private final IOConsole Blue = new IOConsole(AnsiColor.BLUE); + private static final IOConsole Purple = new IOConsole(AnsiColor.PURPLE); + private static final IOConsole Cyan = new IOConsole(AnsiColor.CYAN); + private Integer betType = 0; + private IOConsole console = new IOConsole(); + private int d1Value; + private int d2Value; + private int d3Value; + private int bet; + private int winnings; + private int balance = 500; + Dice d6 = new Dice(1); + + + public static void playChuckALuckGame() { + ChuckALuckGame game = new ChuckALuckGame(); + game.welcome(); + game.printRules(); + System.out.println(game.welcomeDice1()); + System.out.println(game.welcomeDice2()); + Boolean quit = false; + System.out.print("YOUR CURRENT BALANCE IS: " + game.balance + "\n"); + game.setBet(); + while(!quit) { + game.askBetType(); + game.tossDice1(); + game.tossDice2(); + game.tossDice3(); + game.showRolls(); + game.printWinOrLose(); + System.out.println("SUM: " + game.sumDice() + "\n"); + game.winYN(); + game.adjustBalance(); + System.out.println("YOUR NEW BALANCE IS: " + game.balance + "\n\n"); + Integer input = Purple.getIntegerInput("PLAY AGAIN?\n\n" + + "1.YES 2.NO 3.CHANGE BET"); + if (input == 2) { + quit = true; + } else if (input == 3) { + game.setBet(); + } + } + } + public void setBet () { + this.bet = Yellow.getIntegerInput("ENTER YOUR WAGER: "); + } + + + public Integer adjustBalance() { + if (winYN()) { + balance += bet*1.5; + } else if(winYN() && betType == 3) { + balance += bet*500; + } else balance -= bet; + return balance; + } + + public void welcome() { + Blue.println("\n\n\n"+ + "██████ ██ ██ ██ ██ ██████ ██ ██ █████ ██ ██ ██ ██████ ██ ██ ██\n" + + "██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██\n" + + "██ ███████ ██ ██ ██ █████ ███████ ██ ██ ██ ██ █████ ██\n" + + "██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \n" + + "██████ ██ ██ ██████ ██████ ██ ██ ██ ██ ███████ ██████ ██████ ██ ██ ██"); + + } + public String welcomeDice1() { + return + " ____\n" + + " /\\' .\\ _____\n" + + "/: \\___\\ / . /\\\n" + + "\\' / . / /____/..\\\n" + + " \\/___/ \\' '\\ /\n" + + " \\'__'\\/"; + } + public String welcomeDice2() { + return + "\t ____\n" + + "\t /\\': \\\n" + + "\t/ \\___\\\n" + + "\t\\' / : /\n" + + "\t \\/___/\n"; + } + public void printRules() { + System.out.println("\nTRY YOUR LUCK AGAINST THE ROLLS OF THE DICE!"); + } + public Integer askBetType() { + betType =Yellow.getIntegerInput("\nWHAT DO YOU WANT TO BET ON? \n\n" + + "1. HIGH\n" + + // -- TOTAL OF 3 DICE > 10 + "2. LOW\n" + + // -- TOTAL OF 3 DICE < 11 + "3. FIELD\n" + + // -- Total of 3 dice < 8 OR > 12 + "4. TRIPLES"); + // -- FEELING LUCKY?? WIN BIG IF ALL 3 DICE SHOW THE SAME NUMBER! + return betType; + } + + public Integer tossDice1() { + d1Value = d6.tossAndSum(); + return d1Value; + } + public Integer tossDice2() { + this.d2Value = d6.tossAndSum(); + return d2Value; + } + public Integer tossDice3() { + this.d3Value = d6.tossAndSum(); + return d3Value; + } + + public void showRolls() { + System.out.println("\nROLLS: " + d1Value + " " + d2Value + " " + d3Value); + } + public Integer sumDice() { + return d1Value + d2Value + d3Value; + } + + +// public boolean resultIsTriple() { +// return tossDice1() == tossDice2() && tossDice1() == tossDice3(); +// } +// public boolean resultIsField() { +// return sumDice() < 8 && sumDice() > 12; +// } +// public boolean isLow() { +// return sumDice() < 11; +// } + + public boolean winYN() { + Integer sum = sumDice(); + if (betType == 1 && sum > 10) { + return true; + } else if (betType == 2 && sum < 11) { + return true; + } else if (betType == 3 && (sum < 8 && sum > 12)) { + return true; + } else if (betType == 4 && (tossDice1() == tossDice2() && tossDice1() == tossDice3())) { + return true; + } + else return false; + } + + public void printWinOrLose() { + if (winYN()) { + Green.println("*********************"); + Green.println("YOU WIN!!"); + Green.println("*********************\n"); + } else { + Red.println("*********************"); + Red.println("OH NO! YOU LOST."); + Red.println("*********************\n"); + } + } + + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + playChuckALuckGame(); + + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckPlayer.java new file mode 100644 index 00000000..062f635e --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckPlayer.java @@ -0,0 +1,24 @@ +package com.github.zipcodewilmington.casino.games.chuckaluck; + +import com.github.zipcodewilmington.Casino; +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.games.Player; + +public class ChuckALuckPlayer extends Player implements PlayerInterface { + + Player player; + CasinoAccount casinoAccount; + + public ChuckALuckPlayer(){ + } + + public Player getPlayer(){ + return this.player; + } + + @Override + public CasinoAccount getCasinoAccount() { + return casinoAccount; + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/Board.java b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/Board.java new file mode 100644 index 00000000..b92a1b4c --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/Board.java @@ -0,0 +1,46 @@ +package com.github.zipcodewilmington.casino.games.connectfour; + +import com.github.zipcodewilmington.utils.AnsiColor; +import com.github.zipcodewilmington.utils.IOConsole; + +public class Board { + public static final String ANSI_YELLOW = "\u001B[33m"; //replace with AnsiColor enums + private static int length = 15; + private static int width = 7; + public static final Character[][] board = new Character[width][length]; + + + public Board(Character[][] matrix) { + } + + //creates board, NOT displays + static void createGameBoard() { + for (int row = 0; row < board.length; row++) { + for (int col = 0; col < board[row].length; col++) { + if (col % 2 == 0) board[row][col] = '|'; + else { + board[row][col] = 'O'; + } + //top row, "lid" + if (row == 0) board[row][col] = '_'; + } + } + } + + + static void displayGameBoard() { + //TODO number rows to better user's understanding + int colNums = 0; + for (Character[] row : board) { +// System.out.print(rowNums++); + for (Character ch : row) { + System.out.print(ANSI_YELLOW + ch); + System.out.print("\t"); + } + System.out.println(""); + } + System.out.println("\t1\t\t2\t\t3\t\t4\t\t5\t\t6\t\t7"); + } + + +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFour.java b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFour.java new file mode 100644 index 00000000..6fe074ad --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFour.java @@ -0,0 +1,245 @@ +package com.github.zipcodewilmington.casino.games.connectfour; + +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.utils.AnsiColor; +import com.github.zipcodewilmington.utils.IOConsole; + +import java.util.*; +import static com.github.zipcodewilmington.casino.games.connectfour.Board.*; + + +public class ConnectFour implements GameInterface { +// static ArrayList userPositions = new ArrayList<>(); +// static ArrayList cpuPositions = new ArrayList<>(); +// List userTokens = new ArrayList<>(); +// List cpuTokens = new ArrayList<>(); +// static Map indexTracker = new HashMap<>(); + + public void playConnectFour() { + + final String ANSI_YELLOW = "\u001B[33m"; //replace with AnsiColor enums + final String ANSI_RED = "\u001B[31m"; + AnsiColor color; + + Scanner sc = new Scanner(System.in); + ConnectFourPlayer cfPlayer = new ConnectFourPlayer(); + Board gameBoard; + IOConsole con = new IOConsole(); + + Token userToken = new Token(); + int round = 1; + Character player = 'R'; + + int col; + boolean winner = false; + boolean allowedPlacement; + + //public static void main(String[] args) { +// Character[][] board = { +// {'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'}, +// {'|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|'}, +// {'|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|'}, +// {'|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|'}, +// {'|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|'}, +// {'|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|'}, +// {'|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|', 'O', '|'}, +// {'|', '-', '|', '-', '|', '-', '|', '-', '|', '-', '|', '-', '|', '-', '|'}, +// }; +// placeUserPosition(board, "user"); +// System.out.print(userToken); + + gameBoard = new Board(board); + createGameBoard(); + + + while (winner == false && round <= 42) { + + do { + displayGameBoard(); + con.print("Round #" + round + "\nPlayer " + player + + " , enter a number to choose column:"); + cfPlayer.setPositionPlacement(sc.nextInt()); + col = cfPlayer.getPositionPlacement() * 2 - 1; + allowedPlacement = checkPlacement(col, board); + + } while (allowedPlacement == false); + for (int row = board.length - 1; row >= 1; row--) { + if (board[row][col] == 'O') { + board[row][col] = player; //TODO + break; + } + } + winner = isWinner(player, board); + + if (player == 'R') { + player = 'B'; + } else { + player = 'R'; + } + round++; + } + displayGameBoard(); + System.out.println(""); + + if (winner) { + if (player == 'R') { + System.out.println("Black won!"); + } else { + System.out.println("Red won!"); + } + System.out.println("No winners, tied game"); + } + + +// ConnectFour(ConnectFourPlayer player) { +// this.player = cfPlayer; +// } + +// ConnectFour() { +// } + +/* + static void placeUserPosition(Character[][] board, String user) { + char symbol = 'X'; + boolean allowedPlacement = true; + int roundCounter = 1; + + while (true) { //replace w try, catch block + System.out.println("Round " +roundCounter +"\n"+ + "Enter a position to place your token: "); + cfPlayer.setPositionPlacement(sc.nextInt()); // setting player position based on user input + int pos = cfPlayer.getPositionPlacement(); //return player's position + + allowedPlacement = checkPlacement(pos, board); + userToken.setSymbol(symbol); + Character tok = userToken.getSymbol(); + + switch (pos) { + //y then x + case 1: + board[6][1] = symbol;//column1 + userPositions.add(pos); +// indexTracker.put(board, emptyPosition); + break; + case 2: + board[6][3] = tok; //column2 + break; + case 3: + board[6][5] = symbol; //column3 + break; + case 4: + board[6][7] = symbol; //column4 + break; + case 5: + board[6][9] = symbol; //column5 + break; + case 6: + board[6][11] = symbol; //column6 + break; + case 7: + board[6][13] = symbol; //column7 + break; + default: + System.out.print("ERROR: invalid number"); + break; + } + roundCounter++; + System.out.println("\n\n"); + + System.out.print(userPositions); + + displayGameBoard(); + + } + +// while (winner==false) { +// +// if (position>7 || position<0) { +// System.out.print("ERROR: invalid number"); +// } +// else { +// board[6][position] = symbol; +// } +// } + + + } +*/ + } + + static boolean checkPlacement ( int col, Character[][] board){ + if (col < 1) { //TODO + System.out.print("ERROR: invalid number"); + return false; + } else if (board[1][col] != 'O') { //TODO + return false; + } + return true; + } + + + static boolean isWinner (Character player, Character[][]board){ + for (int row = 1; row < board.length; row++) { + for (int col = 1; col < board[1].length - 2; col++) { + if (board[row][col] == player && + board[row][col + 2] == player && + board[row][col + 4] == player && + board[row][col + 6] == player) { + return true; + } + } + } + + for (int row = 1; row < board.length - 3; row++) { + for (int col = 1; col < board[1].length; col++) { + if (board[row][col] == player && + board[row + 2][col] == player && + board[row + 4][col] == player && + board[row + 6][col] == player) { + return true; + } + } + } + + for (int row = 3; row < board.length; row++) { + for (int col = 1; col < board[1].length - 3; col++) { + if (board[row][col] == player && + board[row - 2][col + 2] == player && + board[row - 4][col + 4] == player && + board[row - 6][col + 6] == player) { + return true; + } + } + } + + for (int row = 1; row < board.length - 3; row++) { + for (int col = 1; col < board[1].length - 3; col++) { + if (board[row][col] == player && + board[row + 2][col + 2] == player && + board[row + 4][col + 4] == player && + board[row + 6][col + 6] == player) { + return true; + + } + } + } + return false; + } + + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + playConnectFour(); + } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFourPlayer.java b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFourPlayer.java new file mode 100644 index 00000000..afed7312 --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFourPlayer.java @@ -0,0 +1,40 @@ +package com.github.zipcodewilmington.casino.games.connectfour; + +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.games.Player; + +public class ConnectFourPlayer extends Player implements PlayerInterface { + int positionPlacement; + Player player; + CasinoAccount casinoAccount; + + public ConnectFourPlayer(Player player, CasinoAccount casinoAccount){ + this.player = player; + this.casinoAccount = casinoAccount; + } + + public ConnectFourPlayer(){ + + } + + public Player getPlayer(){ + return this.player; + } + + public CasinoAccount getCasinoAccount(){ + return casinoAccount; + } + + public int getPositionPlacement() { + return positionPlacement; + } + public void setPositionPlacement(int chosenPosition) { + this.positionPlacement = chosenPosition; + } + +// @Override + //public CasinoAccount getCasinoAccount() { +// return null; +// } +} diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/Token.java b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/Token.java new file mode 100644 index 00000000..c000306c --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/connectfour/Token.java @@ -0,0 +1,43 @@ +package com.github.zipcodewilmington.casino.games.connectfour; + +import com.github.zipcodewilmington.utils.AnsiColor; + +public class Token { + private Character symbol; + private AnsiColor color; + private static final String ANSI_RED = "\u001B[31m"; + private static final String ANSI_BLACK = "\u001B[30m"; + + Token() { + + } + + public Character getSymbol() { + return this.symbol; + } + + public void setSymbol(Character symbol) { + this.symbol = symbol; + } + + +// Token() { +// this.symbol = 'O'; +// this.ansiColor = AnsiColor.YELLOW; +// } +// Token() { +// } +// Token(AnsiColor color, Character ch) { +// } + +// Token(Character ch) { +// this.symbol = ch; +// System.out.print(ANSI_RED+Character.toUpperCase(symbol)); +// } + + +// @Override +// public String toString() { +// return color+String.valueOf(symbol); +// } +} 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..41cbf7b3 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,82 @@ package com.github.zipcodewilmington.casino.games.slots; +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; + +import java.util.Objects; +import java.util.Random; +import java.util.Scanner; + /** * Created by leon on 7/21/2020. */ -public class SlotsGame { +public class SlotsGame implements GameInterface { + + // public static void main(String[] args){ + + public static void playSlotsGame(){ + + final String RED_BRIGHT = "\033[0;91m"; // RED + final String TEXT_RESET = "\u001B[0m"; + + Random random = new Random(); + int num1; + int num2; + int num3; + Scanner scan = new Scanner(System.in); + String playerInput; + + + do { + System.out.println("Press 1 to play or Q to quit."); + playerInput = scan.nextLine(); + System.out.println("\n"); + + num1 = random.nextInt(10); + num2 = random.nextInt(10); + num3 = random.nextInt(10); + + if(Math.random() <= 0.20) { + System.out.println( RED_BRIGHT + "CHERRY | CHERRY | CHERRY" + TEXT_RESET + "\n" + + "Plus 2 tokens! \n"); + } else { + + System.out.println("$$$$$$$$$$$$$$$\n" + + " " + num1 + " || " + num2 + " || " + num3 + " \n" + + "$$$$$$$$$$$$$$$"); + + if (num1 == 7 && num2 == 7 && num3 == 7) { + //win jackpot + System.out.println("\n" + + "Jackpot!! Congratulations!! ;D \n" + + "Plus 1,000 tokens!"); + ; + + } else if (num1 == num2 && num1 == num3) { + //win tokens + System.out.println("\n" + + "Winner!! Plus 50 tokens! \n"); + } else { + System.out.println("\n" + + "Loser. Try again! \n"); + } + } + } while (Objects.equals(playerInput, "1")); + } + + @Override + public void add(PlayerInterface player) { + + } + + @Override + public void remove(PlayerInterface player) { + + } + + @Override + public void run() { + playSlotsGame(); + + } } 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..1dc53ac0 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,36 @@ package com.github.zipcodewilmington.casino.games.slots; +import com.github.zipcodewilmington.casino.CasinoAccount; +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.games.Player; + /** * Created by leon on 7/21/2020. */ -public class SlotsPlayer { +public class SlotsPlayer extends Player implements PlayerInterface { + Player player; + private int bet; + CasinoAccount casinoAccount; + + public SlotsPlayer(Player player, CasinoAccount casinoAccount){ + this.player = player; + this.casinoAccount = casinoAccount; + } + + public SlotsPlayer(){ + + } + + public Player getPlayer(){ + return this.player; + } + + public CasinoAccount getCasinoAccount(){ + return casinoAccount; + } + + // public void setCasinoAccount(){ + //} + + } \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/CasinoAccountManagerTest.java b/src/test/java/com/github/zipcodewilmington/casino/CasinoAccountManagerTest.java new file mode 100644 index 00000000..a14fe7ec --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/CasinoAccountManagerTest.java @@ -0,0 +1,4 @@ +import static org.junit.Assert.*; +public class CasinoAccountManagerTest { + +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckGameTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckGameTest.java new file mode 100644 index 00000000..80f13aff --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckGameTest.java @@ -0,0 +1,4 @@ +import static org.junit.jupiter.api.Assertions.*; +class ChuckALuckGameTest { + +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckPlayerTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckPlayerTest.java new file mode 100644 index 00000000..90e48d5e --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/chuckaluck/ChuckALuckPlayerTest.java @@ -0,0 +1,4 @@ +import static org.junit.Assert.*; +public class ChuckALuckPlayerTest { + +} \ No newline at end of file diff --git a/src/test/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFourTest.java b/src/test/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFourTest.java new file mode 100644 index 00000000..78b88f62 --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/connectfour/ConnectFourTest.java @@ -0,0 +1,10 @@ +package com.github.zipcodewilmington.casino.games.connectfour; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ConnectFourTest { + +} \ 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..e720576a --- /dev/null +++ b/src/test/java/com/github/zipcodewilmington/casino/games/slots/SlotsGameTest.java @@ -0,0 +1,36 @@ +package com.github.zipcodewilmington.casino.games.slots; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Random; + +import static org.junit.Assert.*; + +public class SlotsGameTest { + + @Test + public void randomNumber(){ + Random rand = new Random(1); + int expected = rand.nextInt(10); + int actual = 5; + Assert.assertEquals(expected, actual); + } + + @Test + public void randomNumber1(){ + Random rand = new Random(2); + int expected = rand.nextInt(10); + int actual = 8; + Assert.assertEquals(expected, actual); + } + + @Test + public void randomNumber2(){ + Random rand = new Random(3); + int expected = rand.nextInt(10); + int actual = 4; + Assert.assertEquals(expected, actual); + } + +} \ No newline at end of file