Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.github.zipcodewilmington.casino.games.numberguess.hangman;

public class Hangman {

}
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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 {
}
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); }
}
Loading