Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

heres my attempt at the question, please help edit: import java.util.*; public c

ID: 3642459 • Letter: H

Question


heres my attempt at the question, please help edit:


import java.util.*;


public class GuessingGame

{

private static Player house;

private static Player player;


private static int wins;

private static int loses;


private static Scanner scan;


/**

* Initialise the game state.

*/

public static void init()

{

house = new Player("House");

player = new Player("Player");

wins = 0;

loses = 0;

scan = new Scanner(System.in);

}


/**

* Used to simulate playing our game.

*/

public static void playGame()

{


char option, playAgain;

int houseHandStrength = 0, playerHandStrength=0;


System.out.println("Welcome to our card guess 1.0 game!");

System.out.println();


do {

// Deal cards to the house and player.

house.acceptDeal(new Card(houseHandStrength), new Card(houseHandStrength));

player.acceptDeal(new Card(playerHandStrength), new Card(playerHandStrength));


System.out.println(house);


// Determine whether the player wants to play this hand.

do {

System.out.print("Deal cards? (Y/N) ");

option = Character.toLowerCase(scan.next().charAt(0));

}

while (option!='n' && option != 'y');


if (option == 'y')

{

System.out.println(player);


// Display hand strength of both players.

houseHandStrength = house.getHandStrength();

playerHandStrength = player.getHandStrength();

System.out.println("The dealer's hand strength is: " + houseHandStrength);

System.out.println("Your hand strength is: " + playerHandStrength);

System.out.println();


// If the player has a stronger hand.

if (player.getHandStrength() > house.getHandStrength())

{

System.out.println("** You won the hand! **");

wins++;

}

else {

System.out.println("The house wins this round!");

loses++;

}

}


// Display the win/lose statistics.

System.out.println("Current wins: " + wins);

System.out.println("Current loses: " + loses);


// Prompt whether the user wants to play again.

do {

System.out.print("Would you like to play again? (Y/N) ");

playAgain = Character.toLowerCase(scan.next().charAt(0));

}while (playAgain != 'n' && playAgain != 'y');


System.out.println();

System.out.println("*******************************************************");

}while (playAgain == 'y');


System.out.println();

System.out.println("Thank you for playing!");

}


public static void main(String[] args)

{

init();

playGame();

}

}




class Card{


private int value;


Card(int value){

this.value = value;

}


public int getValue(){

return value;

}


}

import java.util.*;


class Player{


String name;

Card card1,card2;



public void acceptDeal(Card card1, Card card2){

Random r = new Random();

int value = r.nextInt(13) + 1;

card1 = new Card(value);

value = r.nextInt(13) + 1;

card2 = new Card(value);

}

public Player(String name){

this.name = name;

card1 = null;

card2 = null;

}



public int getHandStrength(){

int strength = card1.getValue() + card2.getValue();

System.out.println(strength);

return strength;

}


}

Explanation / Answer

I think its working it may help you a little here are the three classes separated by these lines

--------------------------------------------------------------------------

import java.util.List;

import java.util.Scanner;


public class CardGuessingGame

{

//-----------------

//Atributes

//-----------------

private Player player;

private Player computer;

//-----------------

//Constructors

//-----------------

public CardGuessingGame(String pName)

{

player = new Player(pName);

computer = new Player("Computer");

}

//-----------------

//Methods

//-----------------

public String getCards()

{

return player.getCard() +" "+ computer.getCard();

}

public void newGame()

{

player.pickNewCards();

computer.pickNewCards();

}

public String getWinner()

{

if(player.getTotal() > computer.getTotal())

{

return player.toString() + " has won!!!!! :)";

}

else return player.toString() + " you lose!!!!! :(";

}

//-----------------

//Main

//-----------------

public final static void main (String [] args)

{

Scanner keyboard = new Scanner(System.in);

char option = 'y';

System.out.println("--------Playin Cards--------");

System.out.println("Please enter your name:");

String name;

name = keyboard.next();

CardGuessingGame game = new CardGuessingGame(name);

while (option == 'y')

{

System.out.println("Do you want to play? y/n");

option = keyboard.next().charAt(0);

if (option == 'y')

{

game.newGame();

System.out.println(game.getCards());

System.out.println(game.getWinner());

}

}

System.out.println("Goodbey!!");

}

}

----------------------------------------------------------------------------

public class Player

{

//-----------------------

//Attributes

//-----------------------

private String name;

private Card cardOne;

private Card cardTwo;

//-----------------------

//Constructors

//-----------------------

public Player(String pName)

{

name = pName;

cardOne = new Card();

cardTwo = new Card();

}

//-----------------------

//Methods

//-----------------------

public int getTotal()

{

return cardOne.getNumber() + cardTwo.getNumber();

}

public String getCard()

{

return name + " your cards are: " + cardOne.getStringNumber() + " of " + cardTwo.getSuit() + " and " + cardTwo.getStringNumber() + " of " + cardTwo.getSuit();

}

public void pickNewCards ()

{

cardOne.randomCard();

cardTwo.randomCard();

}

public String toString()

{

return name;

}

}