Question: Can you help make this java code. Here is the code they gave me public class PaperScissorsRock { Player player1; Player player2; public PaperScissorsRock(Player player1,

Can you help make this java code.

Can you help make this java code. Here is the code they

Here is the code they gave me

public class PaperScissorsRock { Player player1; Player player2; public PaperScissorsRock(Player player1, Player player2) { this.player1 = player1; this.player2 = player2; } public static String whoWon(String player1Move, String player2Move) { if (player1Move.equals(player2Move)) { return "Tie"; } else { if (player1Move.equals("Rock")) { if (player2Move.equals("Scissors")) { return "Player 1"; } else { return "Player 2"; } } else if (player1Move.equals("Scissors")) { if (player2Move.equals("Rock")) { return "Player 2"; } else { return "Player 1"; } } else { if (player2Move.equals("Rock")) { return "Player 1"; } else { return "Player 2"; } } } }

public static void main(String[] args) {

Player player1 = new Player(); Player player2 = new Player(); int player1Wins = 0; for (int i=0; i

System.out.println("Player 1 won " + player1Wins + " times"); } } Then this code

public class Player {

public String go() { double random = Math.random(); if (random

Your task for the practice lab is to create a subclass of Player called Strategicplayer. The StrategicPlayer class should have the following fields and methods: private double percentPaper - the likelihood (between 0 and 1) that the player will choose paper private double percentScissors - the likelihood (between 0 and 1) that the player will choose scissors private double percentRock the likelihood (between 0 and 1) that the player will choose rock public StrategicPlayer(double paper, double scissors, double rock) a constructor that initializes the object's fields The class should also override the go method from the Player superclass to choose paper, scissors or rock in the desired percentages. Modify the driver program so that Player 1 is a Strategic Player instead of a regular Player and re-run the program. Hint: the outcome should be little changed from the original version no matter what percentages you use, because there is no strategy in Paper Scissors Rock

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!