Question: Can you change this code to a state where the card used from the deck is removed from the deck, the player and the computer

Can you change this code to a state where the card used from the deck is removed from the deck, the player and the computer play in turns, when the user enters 2, the turn goes directly to the computer and nothing is added to the user board? import java.util.Random; import java.util.Scanner; public class Game { public static void main (String[] args) { Deck deck = new Deck(); Player computer = new Player(); Player user= new Player(); Player player= new Player(); deck.creatinggamedeck(); System.out.println("game deck"); deck.showCard(deck.gamedeck); System.out.println("game deck 2"); deck.showCard(deck.gamedeck2); System.out.println("shuffled cards"); shuffle(deck.gamedeck); deck.showCard(deck.gamedeck); int drawindex =0; dealingcards(deck.gamedeck,deck.gamedeck2,computer,user); playinggame(computer,user,deck.gamedeck,drawindex); drawcard(computer,user,deck.gamedeck,drawindex); usersturn(user,computer,deck.gamedeck,drawindex); computerturn(user,computer,deck.gamedeck,drawindex); //winner(computer,user); } private static void shuffle(Cards[] deck) { Random r= new Random(); for (int i= deck.length-1; i>0; i--) { int j = r.nextInt(i+1); Cards temp = deck[i]; deck[i]= deck[j]; deck[j] = temp; } } private static void dealingcards(Cards[] gamedeck,Cards[] gamedeck2,Player computer, Player user) { Random r = new Random(); for (int i=0;i<5;i++) { computer.deck[i]= gamedeck[i]; user.deck[i]=gamedeck[gamedeck.length-1-i]; } for (int i=0;i<5;i++) { computer.deck[i+5]= gamedeck2[r.nextInt(gamedeck2.length)]; user.deck[i+5]=gamedeck2[r.nextInt(gamedeck2.length)]; } for (int i=0; i<4;i++) { int randomindex= r.nextInt(10); computer.hand[i]= computer.deck[randomindex]; user.hand[i]= user.deck[randomindex]; } System.out.print("your hand: "); for (int i = 0; i < 4; i++) { System.out.print(user.hand[i].getName() + " "); } System.out.println(); System.out.println("computers hand: "); for (int i = 0; i < 4; i++) { System.out.print(computer.hand[i].getName() + " "); } System.out.println(); } private static void drawcard(Player computer, Player user, Cards [] gamedeck, int drawindex) { if (drawindex

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!