diff --git a/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/hangman/Hangman.java b/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/hangman/Hangman.java new file mode 100644 index 0000000..67d5bdb --- /dev/null +++ b/src/main/java/com/github/zipcodewilmington/casino/games/numberguess/hangman/Hangman.java @@ -0,0 +1,5 @@ +package com.github.zipcodewilmington.casino.games.numberguess.hangman; + +public class Hangman { + +} 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 8cb20c7..58eecee 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,65 @@ package com.github.zipcodewilmington.casino.games.slots; +import java.util.Random; +import java.util.Scanner; -/** - * Created by leon on 7/21/2020. - */ -public class SlotsGame { -} +import com.github.zipcodewilmington.casino.GameInterface; +import com.github.zipcodewilmington.casino.PlayerInterface; + + +public class SlotsGame implements GameInterface{ + private SlotsPlayer player; + private Random random = new Random(); + private String[] symbols = {"🍒", "🍋", "⭐", "🔔", "💎"}; + + @Override + public void add(PlayerInterface player) { + this.player = (SlotsPlayer)player; + } + + @Override + public void remove(PlayerInterface player) { + this.player = null; + } + + + @Override + public void run() { + Scanner scanner = new Scanner(System.in); + System.out.println("Welcome to Slots, " + player.getName() + "!"); + + while (player.getBalance() > 0 ) { + System.out.println("Balance: $" + player.getBalance()); + System.out.print("Enter bet amount (or 0 to quit): "); + double bet = scanner.nextDouble(); + if (bet == 0) { + break; + } + if (bet > player.getBalance()) { + System.out.println("Insufficient balance!"); + continue; + } + + String result = spin(); + System.out.println("Spinning..."); + + String[] reels = result.split(" \\| "); + if (reels[0].equals(reels[1]) && reels[1].equals(reels[2])) { + double winnings = bet * 3; + player.setBalance(player.getBalance() + winnings); + System.out.println("Jackpot! You win $" + winnings); + } else { + player.setBalance(player.getBalance() - bet); + System.out.println("You lose $" + bet); + } + } + System.out.println("Game over! Final balance: $" + player.getBalance()); + } + + public String spin() { + String reel1 = symbols[random.nextInt(symbols.length)]; + String reel2 = symbols[random.nextInt(symbols.length)]; + String reel3 = symbols[random.nextInt(symbols.length)]; + return reel1 + " | " + reel2 + " | " + reel3; + } + +} \ No newline at end of file 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 f89ebd7..fcef631 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,30 @@ package com.github.zipcodewilmington.casino.games.slots; - +import com.github.zipcodewilmington.casino.PlayerInterface; +import com.github.zipcodewilmington.casino.CasinoAccount; /** * Created by leon on 7/21/2020. */ -public class SlotsPlayer { -} \ No newline at end of file +public class SlotsPlayer implements PlayerInterface { + private String name; + private CasinoAccount account;// replaced. double balance of my own so it will take into account for what the casino account for the player has, to place bets. + + public SlotsPlayer(String name, CasinoAccount account) { + this.name = name; + this.account = account; + } + + @Override + public CasinoAccount getArcadeAccount() { + return account; + } + @Override + public String play() { + return name + " is playing Slots YAYYYYY!"; + } + + public String getName() { return name; } + + public double getBalance() { return account.getActiveBalance(); } + + public void setBalance(double amount) { account.setActiveBalance(amount); } +}