Question
how Casks Activity Casino project Copy previous assignment to a new project (ie copy the project folder and modify the new project) casino package Casino
how Casks Activity Casino project Copy previous assignment to a new project (ie copy the project folder and modify the new project) casino package Casino class 1. Update the switch statement for case label Constants.BLACK JACK to do the following a Add the member variable of class Player as an argument to the constructor for class BlackJack b. Call method play
I need help with this assignment. This is what is being asked of me:
This is Code from previous project that involves new instructions:
package casino;
import blackjack.BlackJack; import constants.Constants; import java.util.Scanner; import scratchers.ScratchOffs; import slots.Slots;
public class Casino { private static Scanner scan; private static BlackJack blackjack; private static Player player; private static ScratchOffs scratchers; private static Slots slots;
public static void main(String[] args) { int game = 0; scan = new Scanner(System.in); player = new Player(); game = displayMenu(); switch(game) { case Constants.BLACK_JACK: blackjack = new BlackJack(); break; case Constants.SCRATCH: scratchers = new ScratchOffs(); break; case Constants.SLOTS: slots = new Slots(player); slots.play(); break; default: System.out.println(\"Invalid game selection, please try again\"); } } private static int displayMenu() { int select; do { System.out.println(\"Welcome to the Knights Casino\"); System.out.println(\"\"); System.out.println(\"Select a game to play\"); System.out.println(\"1. Black Jack\"); System.out.println(\"2. Scratch Off Tickets\"); System.out.println(\"3. Slot Machines\"); System.out.println(\"Enter the number of your choice\"); select = scan.nextInt(); } while (select Constants.SLOTS); return select; } }
------------------------------------------------------------------------------------------------------------------------------------
package slots;
import casino.Player; import java.util.Random; import java.util.Scanner; import constants.Constants;
public class Slots { private final int SLOTS = 3; private final char[] SYMBOLS = {'$', '%', '&', '#', '@', '!'}; private Random rand; private char spins[]; private Player player; private boolean play; private Scanner scan; public Slots(Player p) { this.player = p; scan = new Scanner(System.in); rand = new Random(); spins = new char[3]; play = true; } public void play() { int input; System.out.println(\"Let's play the slot machines!\"); System.out.println(\"The bet is $\" + Constants.BET); System.out.println(\"Your cash balance is $\"+ player.getCash()); System.out.println(\"Match two symbols to win $5\"); System.out.println(\"Match all three symbols to win $50\"); if(player.getCash() { System.out.println(\"You don't have enough money to play\"); play = false; } while(play == true) { player.setCash(player.getCash() - Constants.BET); System.out.println(\"Spinning...\"); for(int i=0;i spins[i]=randomSymbol(); System.out.print(spins[i]+\" \"); } System.out.println(\"\"); if(spins[0]==spins[1]&&spins[0]==spins[2]) { System.out.println(\"All three symbols matched, you won $50!\"); player.setCash(player.getCash()+50); } else if(spins[0]==spins[1]||spins[0]==spins[2]||spins[1]==spins[2]) { System.out.println(\"Two symbols matched, you won $5!\"); player.setCash(player.getCash()+5); } else { System.out.println(\"Player didn't receive any money\"); } System.out.println(\"Cash = $\"+player.getCash()); if(player.getCash()>=5) { System.out.print(\"Would you like to spin again (Yes = 1, No = 0)?\"); input=scan.nextInt(); if(input==1) { play=true; } else { play=false; } } else { System.out.println(\"You are out of cash, you cannot play\"); break; } } System.out.println(\"Thank you for playing slots at Knights Casino! Your cash out is $\"+player.getCash()); } private char randomSymbol() { int num=rand.nextInt(SYMBOLS.length); char symbol=' '; switch(num) { case 0: symbol=SYMBOLS[0]; break; case 1: symbol=SYMBOLS[1]; break; case 2: symbol=SYMBOLS[2]; break; case 3: symbol=SYMBOLS[3]; break; case 4: symbol=SYMBOLS[4]; break; case 5: symbol=SYMBOLS[5]; break; } return symbol; } }
------------------------------------------------------------------------------------------------------------------
package casino;
import java.util.Scanner;
public class Player { private String name; private int cash; private Scanner scan; public Player() { scan = new Scanner(System.in); int money; String name; System.out.println(\"Enter player's name: \"); name = scan.next(); System.out.println(\"enter amount of money to play (minimum $5)\"); money = scan.nextInt(); setName(name); setCash(money); } public String getName() { return name; }
public void setName(String name) { this.name = name; }
public int getCash() { return cash; }
public void setCash(int cash) { this.cash = cash; } }
----------------------------------------------------------------------------
package constants;
public class Constants { public static final int BLACK_JACK = 1; public static final int SCRATCH = 2; public static final int SLOTS = 3; public static final int BET = 5; public static final int PAIR_PAYOUT = 5; public static final int TRIPLE_PAYOUT = 50; } ------------------------------------------------------------------------------------------------
The rest of the classes are empty
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started