diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..84a24410a Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 53c83987d..14d9a6ea5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ local.properties .settings/ .loadpath .recommenders +.DS_Store # External tool builders .externalToolBuilders/ diff --git a/README.md b/README.md index 14d017d9b..02c34dd94 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ * `Player` objects should be created upon input from a user. * `Game` interface * Contract which ensures that a class enforces some aspect of _playing_. - * `GamblingGame` interface + * `io.zipcoder.casino.GamblingGame` interface * Contract which ensures that a game enforces some aspect of _waging money_. * `GamblingPlayer` interface * Contract which ensures that a player has some ability to _wage money_. diff --git a/src/Casino Structure.png b/src/Casino Structure.png new file mode 100644 index 000000000..413f2b63f Binary files /dev/null and b/src/Casino Structure.png differ diff --git a/src/Casino Structure.puml b/src/Casino Structure.puml new file mode 100644 index 000000000..cbe321f24 --- /dev/null +++ b/src/Casino Structure.puml @@ -0,0 +1,199 @@ +@startuml +'https://plantuml.com/class-diagram + +Game <|-- GamblingGame +Game <|-- CardGame +GamblingPlayer <|-- Player +GamblingGame <|-- Blackjack +GamblingGame <|-- DiceGame + +DiceGame <|-- Beetle +DiceGame <|-- Craps +CardGame <|-- Blackjack +CardGame <|-- GoFish + + +Display <|-- BeetleDisplay +Display <|-- CrapsDisplay +Display <|-- BlackjackDisplay +Display <|-- GoFishDisplay + + +'INTERFACE +interface Game { +Random +Boolean gameState +checkForWinner() +setPlayer() +} + +interface GamblingGame { +acceptBetFrom() +calculateReward() +calculateLoss() +} + +interface GamblingPlayer { +placeBet() +} + + +'ABSTRACT CLASS +abstract class CardGame{ +Stack decksOfCards +ArrayList playersHand +ArrayList dealersHand +shuffleCards() +dealCards(Int numberOfCards) +skipDeal() + +} + +abstract class DiceGame { +rollDice(numberOfDice) +} + + +'CLASS +class Main{ + +} + +class CasinoEngine { +runCasino() +} + +class Player { +String name +Double accountBalance +getName() +getAccountBalance() +setAccountBalance() +} + +class GoFish { +HashMap +HashMap +exchangeCard() +getNumberOfPairs() +setNumberOfPairs() +} + +class GoFishDisplay { +chooseAPlayerToAsk() +chooseACardtoAskFor() +playerHasCard() +goFish() +pairMade() + +} + +class Blackjack { +HashMap +gotBlackJack(int betPlaced) +standOrHit() +} + +class BlackjackDisplay { +dealersFirstCard() +bustMessage(String whoBusted) +dealersTotal() +dealerStands() +dealerHits() +chooseStandOrHit() +} + +class Craps { +Boolean isNatural() +Boolean isCraps() +Boolean isPoint() +analyzeComeOutRoll() +analyzeFollowingRolls() +'comeBet() +'dontComeBet() +'passBet() +'dontPassBet() +'fieldBet() +'bigSixOrEightBet() +getTypeOfBet() +} + +class CrapsDisplay { +rulesMenu() +optionsMenu() +shooterScores() +shooterSevenedOut() +push() +oneRollBetLoss() +onRollBetWin() +natural() +craps() +shooterRolled() +setTypeOfBet() +comeOutRoll() + +} + +class Beetle { +createNextImage() +} + +class BeetleDisplay { +drawBugHead() +drawBugBody() +drawBugLeg1() +drawBugLeg2() +drawBugLeg3() +drawBugLeg4() +playerBugComplete() +opponentBugComplete() +repeatRoll() +bodyPartValue() +} + +class PlayerWarehouse { +playerGroup +getPlayer() +} + +class Console { +Scanner input +PrintStream output +print() +println() +getStringInput() +getDoubleInput() +getLongInput() +getIntegerInput() +} + +class Display { +String currentDisplay + +errorMessage() + +'casino messages +welcomeMessage() +gamesMenu() +lowFundsWarning() +zeroFundsWarning() + +'game messages +rollResult() +dealResult() +youWin() +youLose() +doYouWantToBet() + +'new user messages +userId() +requestUserId() +initialDeposit() + +'returning user messages +welcomeBack() + +} + + +@enduml \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/Beetle.java b/src/main/java/io/zipcoder/casino/Beetle.java new file mode 100644 index 000000000..bfa7935d0 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Beetle.java @@ -0,0 +1,4 @@ +package io.zipcoder.casino; + +public class Beetle { +} diff --git a/src/main/java/io/zipcoder/casino/BeetleDisplay.java b/src/main/java/io/zipcoder/casino/BeetleDisplay.java new file mode 100644 index 000000000..12e3d310e --- /dev/null +++ b/src/main/java/io/zipcoder/casino/BeetleDisplay.java @@ -0,0 +1,71 @@ +package io.zipcoder.casino; + +import io.zipcoder.casino.utilities.Console; + +import java.util.Arrays; + +public class BeetleDisplay extends Display { + + String[][] beetle = new String[][]{{"\\","0","/"}, + {"⎛","|","⎞"}, + {"⎝","|","⎠"}, + {"/","⏝","\\"} + }; + + public BeetleDisplay() { + } + + public void rules() { + setPrintCurrentDisplay("Draw the beetle before your opponent and win big!\nThe rules are simple:\nEach side of the die corresponds to a part of the beetle." + + "\nIf you roll a number, you get to draw that part.\nIf you roll the same number again, you do not get to add to your beetle." + + "\nBetween each roll you will add to your wager.\nThe first person to draw a beetle keeps the purse." + + "\nIf both players complete their beetle on the same set of rolls the wagers are returned." + + "\n\nWhat to draw for each roll:" + + "\n1 - head\n2 - body\n3 - left front leg\n4 - right front leg\n5 - left back leg\n6 - right back leg"); + } + + public void drewLeg() { + setPrintCurrentDisplay("You added a leg to your beetle!"); + } + + public void drewBody() { + setPrintCurrentDisplay("You drew your beetle's body!"); + } + + public void drewHead() { + setPrintCurrentDisplay("You drew your beetle's head!"); + } + + public void yourBugIsComplete() { + setPrintCurrentDisplay("Your beetle is complete!"); + } + + public void opponentsBugisComplete() { + setPrintCurrentDisplay("Your opponents beetle is complete."); + } + + public void bothBeetlesComplete() { + setPrintCurrentDisplay("You both drew beetles. The game is a tie."); + } + + public void repeatedRollResult() { + setPrintCurrentDisplay("You already rolled that number."); + } + + //Beetle Body Parts + public void getBeetleComplete() { + //System.out.println(Arrays.deepToString(beetle)); + /*for (String[] row : beetle) { + System.out.println(Arrays.deepToString(row));*/ + for (int i = 0; i < beetle.length; i++) { + for (int j = 0; j < beetle[i].length; j++) { + System.out.print(beetle[i][j] + " "); + } + System.out.println(); + } + } + + public void getCurrentBeetle() { + + } +} \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/BlackJackDisplay.java b/src/main/java/io/zipcoder/casino/BlackJackDisplay.java new file mode 100644 index 000000000..5c92b7ceb --- /dev/null +++ b/src/main/java/io/zipcoder/casino/BlackJackDisplay.java @@ -0,0 +1,100 @@ +package io.zipcoder.casino; + +public class BlackJackDisplay extends Display { + + public void rules() { + setPrintCurrentDisplay("Your goal is to draw cards that total 21, or come closer to 21 than the dealer without going over"+ + + "\nMake a bet from $1 to all-in, receive your cards" + + + "\nThe dealer will give you two blackjack cards and show one of his cards, decide if you want to double your bet" + + + "\nYou can double your bet any time before you hit OR stand and split your bet if you get two cards of the same value." + + + "\nConsider if you want to ‘hit’" + + + "\nYou have an option to add more blackjack cards by choosing 'hit', but you lose automatically if your value of cards exceeds 21." + + + "\nChoose 'stand' when you are ready to play your hand. learn the dealer’s hand" + + + "\nThe dealer will reveal his hidden blackjack card and must always hit if they have 16 or lower. They will stop hitting if they have 17 or more." + + + "\nYou win when the combined value of your cards is greater than that of the dealer."+ + + "\nYou lose if you have a lower score than the dealer, or if the total of your cards exceeds 21."); + + //TIPS + /*"\nThe dealer and each player start with two cards. The dealer’s first card faces up, the second faces down."+ + + "\nFace cards each count as 10, Aces count as 1 or 11, all others count at face value."+ + + "\nAn Ace with any 10, Jack, Queen, or King is a “Blackjack.”:");*/ + } + + public void dealtHand(){ + + setPrintCurrentDisplay("You were dealt "); + } + + public void hitOrStand(){ + + setCurrentDisplay("Do you want to hit or stand?"); + } + + public void dealerHit() { + + setPrintCurrentDisplay("Your hand total is "); + } + + public void playerHit(){ + + setPrintCurrentDisplay("You hit 21!"); + + } + + public void dealerStand() { + + setPrintCurrentDisplay("Do you want to hit or stand?"); + + } + + public void bust(){ + + setPrintCurrentDisplay("You passed 21! Bust..."); + } + + public void dealerBust(){ + + setPrintCurrentDisplay("The dealer busted."); + } + + public void wonGame(){ + + setPrintCurrentDisplay("You win"); + + } + + public void lostGame(){ + + setPrintCurrentDisplay("You lost"); + } + + public void blackJack(){ + + setPrintCurrentDisplay("You got Black Jack!"); + + } + + public void splitPairs() { + + setPrintCurrentDisplay("Would you like to split pairs?"); + + } + + public void doubleDown() { + + setPrintCurrentDisplay(""); + + } + +} \ No newline at end of file diff --git a/src/main/java/io/zipcoder/casino/CardGame.java b/src/main/java/io/zipcoder/casino/CardGame.java new file mode 100644 index 000000000..6130eb046 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CardGame.java @@ -0,0 +1,56 @@ +package io.zipcoder.casino; + +import java.util.ArrayList; +import java.util.Random; +import java.util.Stack; + +public abstract class CardGame implements GamblingGame { + + Stack deckOfCards; + ArrayList playersHand; + ArrayList dealersHand; + ArrayList deck; + + + public CardGame() { + this.deck = new ArrayList(52); + } + + public void createNewDeck() { + String[] suits = new String[]{"Clubs", "Diamonds", "Hearts", "Spades"}; + // Set zeroth element to null to indicate an unused element (only valid ranks from 1-13) + String[] ranks = new String[]{null, "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"}; + + for (int suit = 0; suit <=3; suit++) { + for (int rank = 1; rank <= 13; rank++) { + this.deck.add(ranks[rank] + " of " + suits[suit]); + } + } + } + + public void shuffleCards() { + ArrayList temp = new ArrayList(); + while(!this.deck.isEmpty()) { + int randCard = (int) (Math.random() * deck.size()); + temp.add(deck.get(randCard)); + } + this.deck = temp; + } + + public void dealCards(int numberOfCards) { + int i = 0; + while (i < numberOfCards * 2) { + if (i < numberOfCards) { + this.playersHand.add(this.deck.get(i)); + } else if (i >= numberOfCards) { + this.dealersHand.add(this.deck.get(i)); + } + this.deck.remove(i); + } + } + + public void skipDeal() { + // ??? + } + +} diff --git a/src/main/java/io/zipcoder/casino/Casino.java b/src/main/java/io/zipcoder/casino/Casino.java index 86953f995..bbb8982a2 100644 --- a/src/main/java/io/zipcoder/casino/Casino.java +++ b/src/main/java/io/zipcoder/casino/Casino.java @@ -1,8 +1,24 @@ package io.zipcoder.casino; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 2d9a6333640d23c5de20f3343a85c18403c50a0c +import io.zipcoder.casino.utilities.Console; +import java.util.Scanner; + +<<<<<<< HEAD +>>>>>>> 17106eff69db6462352572b1842f4e0083c113dc +======= + +>>>>>>> 2d9a6333640d23c5de20f3343a85c18403c50a0c public class Casino { public static void main(String[] args) { // write your tests before you start + Display display = new Display(); + System.out.println(display.helloMessage()); + display.getUserInput("Welcome whats your name?"); } } diff --git a/src/main/java/io/zipcoder/casino/CrapsDisplay.java b/src/main/java/io/zipcoder/casino/CrapsDisplay.java new file mode 100644 index 000000000..96bbed9c1 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/CrapsDisplay.java @@ -0,0 +1,76 @@ +package io.zipcoder.casino; + +public class CrapsDisplay extends Display { + + public void printRulesMenu1(){ + setPrintCurrentDisplay("Welcome to Craps!\nIn Craps, the 'shooter' rolls two dice repeatedly.\nTheir first roll, the 'come out roll,' has three potential outcomes.\nA 7 or 11 total is a pass. A 2, 3, or 12 is craps. Anything else is a point.\nYou can bet 'pass' (the shooter rolls a pass) or 'don't pass' (the shooter rolls craps) for 1 to 1 payout.\nThe shooter keeps rolling until a point is set. On a point outcome, the number rolled is saved.\nNow, the shooter can 'come' by hitting the point outcome again, or 'seven out,' ending the round by rolling a 7.\nYou can bet 'come' (shooter hits point before sevening out) or 'don't come' (vice versa) for 1 to 1 payout."); + } + + public void printRulesMenuMid(){ + setPrintCurrentDisplay("Type rules2 for more technical rules."); + } + + public void printRulesMenu2(){ + setPrintCurrentDisplay("There are a number of extra bets you can make, called propositions.\nOne-roll propositions are a bet that the next roll will land on a specific number, with variable payouts.\n6 or 8- 9 to 1 payout. 4 or 10- 7 to 1. 2 or 12- 30 to 1. 3 or 11- 15 to 1. Craps- 7 to 1. 7- 4 to 1.\nField bets are the final one-roll bet. Rolling 3, 4, 9, 10, or 11 pays 1 to 1. Rolling 2 or 12 pays 2 to 1.\nPlace bets can be performed once the point is known. You're betting that a specific different point option will be rolled- this has 1 to 1 payout.\nThat's every bet in Craps! Have fun!"); + } + + public void printOptionsMenu1(){ + setPrintCurrentDisplay("You can make a pass bet, a don't pass bet, or a proposition."); + } + + public void printOptionsMenu2(){ + setPrintCurrentDisplay("You can make a come bet, a don't come bet, or a proposition."); + } + + public void printShooterScores(){ + setPrintCurrentDisplay("The shooter got the point!"); + } + + public void printShooterSevenedOut(){ + setPrintCurrentDisplay("The shooter sevened out..."); + } + + public void printPush(){ + setPrintCurrentDisplay("Your bet is a push."); + } + + public void printOneRolLBetLoss(){ + setPrintCurrentDisplay("Your one-roll proposition failed..."); + } + + public void printOneRollBetWin(){ + setPrintCurrentDisplay("You won your one-roll proposition!"); + } + + public void printNatural(){ + setPrintCurrentDisplay("It's a natural!"); + } + + public void printCraps(){ + setPrintCurrentDisplay("It's craps!"); + } + + public void printShooterRolled(){ + setPrintCurrentDisplay("The shooter rolled a " + 5); + } + + public void printSetTypeOfBet(){ + setPrintCurrentDisplay("What kind of bet do you want to make? You can also type 'options' or 'help'."); + } + + public void printComeOutRoll(){ + setPrintCurrentDisplay("Here's the come out roll..."); + } +} + + + + + + + + + + + + diff --git a/src/main/java/io/zipcoder/casino/DiceGame.java b/src/main/java/io/zipcoder/casino/DiceGame.java new file mode 100644 index 000000000..ba4e70688 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/DiceGame.java @@ -0,0 +1,19 @@ +package io.zipcoder.casino; + +import java.util.Random; + +abstract class DiceGame implements GamblingGame { + + + public Integer diceRollSum(int i) { + Random random = new Random(); + Integer thisToss = 0; + + while (i >= 1) { + int randomGen = (random.nextInt(6) + 1); + thisToss += randomGen; + i--; + } + return thisToss; + } +} diff --git a/src/main/java/io/zipcoder/casino/Display.java b/src/main/java/io/zipcoder/casino/Display.java new file mode 100644 index 000000000..47da2fece --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Display.java @@ -0,0 +1,184 @@ +package io.zipcoder.casino; +<<<<<<< HEAD + +======= +>>>>>>> 2d9a6333640d23c5de20f3343a85c18403c50a0c +import io.zipcoder.casino.utilities.Console; + +import java.io.InputStream; +import java.io.PrintStream; +import java.util.ArrayList; + +import java.util.Scanner; + +public class Display { + + String currentDisplay; + + private Scanner s; + private InputStream in; + private PrintStream out; + + private Console c; + + public Display(){ + + // INPUT/OUTPUT + this.in = System.in; + this.out = System.out; + this.c = new Console(in, out); + + this.currentDisplay = ""; + } + + // UPDATE/PRINT CURRENT DISPLAY + public void setCurrentDisplay(String newDisplay){ + this.currentDisplay = newDisplay; + } + + public void printCurrentDisplay(){ + System.out.println(currentDisplay); + } + + public void setPrintCurrentDisplay(String newDisplay){ + this.setCurrentDisplay(newDisplay); + this.printCurrentDisplay(); + } + + + // WELCOME MESSAGING + public void printWelcomeMessage() { + this.setPrintCurrentDisplay( + "'########:'####:'########::::::'######:::'#######::'########::'########::::\n"+ + "..... ##::. ##:: ##.... ##::::'##... ##:'##.... ##: ##.... ##: ##.....:::::\n"+ + ":::: ##:::: ##:: ##:::: ##:::: ##:::..:: ##:::: ##: ##:::: ##: ##::::::::::\n"+ + "::: ##::::: ##:: ########::::: ##::::::: ##:::: ##: ##:::: ##: ######::::::\n"+ + ":: ##:::::: ##:: ##.....:::::: ##::::::: ##:::: ##: ##:::: ##: ##...:::::::\n"+ + ": ##::::::: ##:: ##::::::::::: ##::: ##: ##:::: ##: ##:::: ##: ##::::::::::\n"+ + " ########:'####: ##:::::::::::. ######::. #######:: ########:: ########::::\n"+ + "........::....::..:::::::::::::......::::.......:::........:::........:::::\n"+ + ":'######:::::'###:::::'######::'####:'##::: ##::'#######::\n"+ + "'##... ##:::'## ##:::'##... ##:. ##:: ###:: ##:'##.... ##:\n"+ + " ##:::..:::'##:. ##:: ##:::..::: ##:: ####: ##: ##:::: ##:\n"+ + " ##:::::::'##:::. ##:. ######::: ##:: ## ## ##: ##:::: ##:\n"+ + " ##::::::: #########::..... ##:: ##:: ##. ####: ##:::: ##:\n"+ + " ##::: ##: ##.... ##:'##::: ##:: ##:: ##:. ###: ##:::: ##:\n"+ + ". ######:: ##:::: ##:. ######::'####: ##::. ##:. #######::\n"+ + ":......:::..:::::..:::......:::....::..::::..:::.......:::\n\n"+ + "WELCOME TO ZIP CODE CASINO, LOCATED IN WILMINGTON, DE!" + ); + } + + public void printWelcomeBackMessage(String name, int getAccountBalance) { + this.setPrintCurrentDisplay( + "Welcome back " + name + "!\n"+ + "Your current account balance is " + getAccountBalance + "." + ); + } + + + // MENUS + public void printLoginMenu() { + this.setPrintCurrentDisplay( + "What would you like to do?\n" + + "1.Login\n" + + "2.Create New Account" + ); + } + + public void printGamesMenu() { + this.setPrintCurrentDisplay( + "Pick a Game to Play:\n"+ + " 1. BlackJack\n" + + " 2. Craps\n" + + " 3. Beetle\n" + + " 4. GoFish\n" + ); + } + + // ERROR MESSAGING + public void printErrorMessage() { + this.setPrintCurrentDisplay("Invalid Input!"); + } + + + // FUNDS MESSAGING + public void printAccountBalance(double accountBalance) { + this.setPrintCurrentDisplay( + "Account Balance: " + accountBalance + ); + } + + public void printLowFundsWarning(double accountBalance){ + this.setPrintCurrentDisplay( + "WARNING: YOUR FUNDS ARE GETTING LOW!\n"+ + "Please consider making a deposit.\n" + ); + this.printAccountBalance(accountBalance); + + } + + public void printZeroFundsWarning() { + this.setPrintCurrentDisplay( + "WARNING: YOUR ACCOUNT BALANCE HAS REACHED $0.00.\n"+ + "PLEASE MAKE A DEPOSIT TO CONTINUE PLAYING." + ); + } + + // GENERIC GAME RESULT MESSAGING + public void printRollResult(Integer[] diceResults) { + String formattedRollResults = ""; + for(int i = 0; i < diceResults.length; i++) { + formattedRollResults += "Dice " + (i+1) + ": " + diceResults[i] + "\n"; + } + + this.setPrintCurrentDisplay( + formattedRollResults + ); + } + + public void printDealResult(ArrayList dealResults) { + String formattedDealResults = ""; + for(int i = 0; i < dealResults.size(); i++) { + formattedDealResults += "Card " + (i+1) + ": " + dealResults.get(i) + "\n"; + } + + this.setPrintCurrentDisplay( + formattedDealResults + ); + } + + // USER SET-UP MESSAGING + public void printUserId(String userName){ + this.setPrintCurrentDisplay( + "UserId: " + userName + ); + } + + public void printRequestUserId() { + this.setPrintCurrentDisplay( + "Please enter username:" + ); + } + + public void printRequestPassword() { + this.setPrintCurrentDisplay( + "Please enter your password:" + ); + } + + public void printRequestInitialDeposit(){ + this.setPrintCurrentDisplay( + "Please enter deposit amount:" + ); + } + + // GENERIC BETTING MESSAGES + public void printRequestBetAmount() { + this.setPrintCurrentDisplay( + "How much money would you like to bet?" + ); + } + + +} diff --git a/src/main/java/io/zipcoder/casino/GamblingGame.java b/src/main/java/io/zipcoder/casino/GamblingGame.java new file mode 100644 index 000000000..1ffe446ec --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GamblingGame.java @@ -0,0 +1,20 @@ +package io.zipcoder.casino; + +public interface GamblingGame { +<<<<<<< HEAD + +======= +>>>>>>> 2d9a6333640d23c5de20f3343a85c18403c50a0c + + public String startGame(); + + public String acceptBetFrom(); + + public String calculateReward(); + + public String calculateLoss(); + + public String endGame(); + + +} diff --git a/src/main/java/io/zipcoder/casino/GamblingPlayer.java b/src/main/java/io/zipcoder/casino/GamblingPlayer.java new file mode 100644 index 000000000..19678e558 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GamblingPlayer.java @@ -0,0 +1,11 @@ +package io.zipcoder.casino; + +public interface GamblingPlayer { + +public String placeBet(); + +public String getName(); + +public Double accountBalance(); + +} diff --git a/src/main/java/io/zipcoder/casino/Game.java b/src/main/java/io/zipcoder/casino/Game.java new file mode 100644 index 000000000..65076adf3 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Game.java @@ -0,0 +1,14 @@ +package io.zipcoder.casino; + +import java.util.Random; + +public interface Game { + Random random =new Random(); + + Integer numberOfPlayers = 0; + Boolean GameState = false; + + public void checkForWinner(); + + public void setPlayer(); +} diff --git a/src/main/java/io/zipcoder/casino/GoFishDisplay.java b/src/main/java/io/zipcoder/casino/GoFishDisplay.java new file mode 100644 index 000000000..7b320c2ea --- /dev/null +++ b/src/main/java/io/zipcoder/casino/GoFishDisplay.java @@ -0,0 +1,37 @@ +package io.zipcoder.casino; + +public class GoFishDisplay extends Display{ + + public void goFishRules(){ + setPrintCurrentDisplay("Two players will be dealt 5 cards each.\nThe object of the game is to have the most pairs when the deck is empty." + + "\nA player creates pairs by asking the other player if they have a specific card in their hand." + + "\nYou must be holding the card the card you request." + + "\n"); + } + + public void goFish(){ + setPrintCurrentDisplay("GO FISH!"); + } + + public void cardFound(){ + setPrintCurrentDisplay("That card is in their hand."); + } + + public void cardNotFound(){ + setPrintCurrentDisplay("Nope. They are not holding that card."); + } + + //only necessary for multiple player games + public void whoWillYouAsk(){ + setPrintCurrentDisplay("Who will you ask?"); + } + + public void cardYouWillAskFor(){setPrintCurrentDisplay("What card will you ask for?");} + + public void opponentAskedFor(){setPrintCurrentDisplay("You opponent asked for a");} + + public void createdAPair() {setPrintCurrentDisplay("Your opponent has a " + ". A pair of " + "'s have been added to your score.");} + + + +} diff --git a/src/main/java/io/zipcoder/casino/Main.java b/src/main/java/io/zipcoder/casino/Main.java new file mode 100644 index 000000000..f747690df --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Main.java @@ -0,0 +1,12 @@ +package io.zipcoder.casino; + +public class Main { + + public static void main(String args[]) { + Display d = new Display(); + BeetleDisplay bd = new BeetleDisplay(); + d.printWelcomeMessage(); + bd.getBeetleComplete(); + + } +} diff --git a/src/main/java/io/zipcoder/casino/Player.java b/src/main/java/io/zipcoder/casino/Player.java new file mode 100644 index 000000000..7dd1bfa12 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/Player.java @@ -0,0 +1,34 @@ +package io.zipcoder.casino; + +public class Player{ + + String name; + Double wallet; + Double currentBet = 0.0; + + public Player(String name, Double initialDeposit) { + this.name = name; + this.wallet = initialDeposit; + } + + + public String getName() { + return name; + } + + + public Double getWallet() { + return wallet; + } + + public void setWallet(Double deposit) { + this.wallet = wallet + deposit; + } + + + public Double makeBet(Double betAmount) { + currentBet = betAmount; + wallet = wallet - currentBet; + return currentBet; + } +} diff --git a/src/main/java/io/zipcoder/casino/PlayerWarehouse.java b/src/main/java/io/zipcoder/casino/PlayerWarehouse.java new file mode 100644 index 000000000..7975268b4 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/PlayerWarehouse.java @@ -0,0 +1,38 @@ +package io.zipcoder.casino; + +import java.util.HashMap; + +public class PlayerWarehouse { + + private HashMap playerGroup; + private HashMap userNamePasswordMap; + + public PlayerWarehouse() { + this.playerGroup = new HashMap(); + this.userNamePasswordMap = new HashMap(); + } + + public Player getPlayer(String userId) { + return this.playerGroup.get(userId); + } + + public boolean validateUniquePlayer(String userId) { + if (userNamePasswordMap.containsKey(userId)) { + return false; + } + return true; + } + + public void addNewPlayer(String userId, Player player, String password) { + playerGroup.put(userId, player); + userNamePasswordMap.put(userId, password); + } + + public boolean validateLoginCredentials(String userId, String password) { + if (userNamePasswordMap.containsKey(userId) && userNamePasswordMap.get(userId) == password) { + return true; + } + return false; + } + +} diff --git a/src/main/java/io/zipcoder/casino/utilities/Console.java b/src/main/java/io/zipcoder/casino/utilities/Console.java index ab896c956..ce2e5cf78 100644 --- a/src/main/java/io/zipcoder/casino/utilities/Console.java +++ b/src/main/java/io/zipcoder/casino/utilities/Console.java @@ -55,6 +55,7 @@ public Long getLongInput(String prompt, Object... args) { } public Integer getIntegerInput(String prompt, Object... args) { + return getLongInput(prompt, args).intValue(); } } diff --git a/src/test/java/io/zipcoder/casino/CasinoTest.java b/src/test/java/io/zipcoder/casino/CasinoTest.java index e92865236..627be16f2 100644 --- a/src/test/java/io/zipcoder/casino/CasinoTest.java +++ b/src/test/java/io/zipcoder/casino/CasinoTest.java @@ -2,4 +2,7 @@ public class CasinoTest { + + // git push test + } diff --git a/src/test/java/io/zipcoder/casino/DisplayTest.java b/src/test/java/io/zipcoder/casino/DisplayTest.java new file mode 100644 index 000000000..a83559138 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/DisplayTest.java @@ -0,0 +1,13 @@ +package io.zipcoder.casino; + +import org.junit.Test; + +public class DisplayTest { + + @Test + public void testPrintStartScreen() { + Display disp = new Display(); + disp.printWelcomeMessage(); + } + +} diff --git a/src/test/java/io/zipcoder/casino/PlayerTest.java b/src/test/java/io/zipcoder/casino/PlayerTest.java new file mode 100644 index 000000000..bb9557db3 --- /dev/null +++ b/src/test/java/io/zipcoder/casino/PlayerTest.java @@ -0,0 +1,74 @@ +package io.zipcoder.casino; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class PlayerTest { + + @Test + public void PlayerConstructorTest() { + //Given + Player player1 = new Player("player1", 100.00); + String actual = player1.getName(); + + //When + String expected = "player1"; + + //Assert + Assert.assertEquals(expected,actual); + } + + @Test + public void PlayerGetAccountBalanceTest() { + //Given + Player player2 = new Player("player1", 500.00); + Double actual = player2.getWallet(); + //When + Double expected = 500.00; + + //Assert + Assert.assertEquals(expected,actual); + } + + @Test + public void PlayerSetAccountBalanceTest() { + //Given + Player player3 = new Player("player1", 500.00); + player3.setWallet(100.00); + Double actual = player3.getWallet(); + //When + Double expected = 600.00; + + //Assert + Assert.assertEquals(expected,actual); + } + @Test + public void PlayerMakeBetTest() { + //given + Player player4 = new Player("player1", 50.00); + Double expected = player4.makeBet(5.0); + + //when + Double actual = 5.0; + //assert + Assert.assertEquals(expected,actual); + + } + + @Test + public void PlayerMakeBetTest2() { + //given + Player player5 = new Player("player1", 50.00); + player5.makeBet(5.0); + Double expected = player5.getWallet(); + + //when + Double actual = 45.0; + //assert + Assert.assertEquals(expected,actual); + + } + +}