Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions