Question: Please help to correct so this below Java code compile and ryn properly, and please send the code back with the changes in the code
Please help to correct so this below Java code compile and ryn properly, and please send the code back with the changes in the code in whole. import java.util.Scanner;
class Human extends Player
private Scanner scanner;
public HumanString name
supername;
scanner new ScannerSystemin;
@Override
public int makeMoveint currentSticks
System.out.printlnname enter number of sticks to take to currentSticks : ;
int sticks scanner.nextInt;
while sticks sticks currentSticks
System.out.printlnInvalid number of sticks. Try again: ;
sticks scanner.nextInt;
return sticks;
abstract class Player
protected String name;
public PlayerString name
this.name name;
public abstract int makeMoveint currentSticks;
class Computer extends Player
public ComputerString name
supername;
@Override
public int makeMoveint currentSticks
int sticks intMathrandomcurrentSticks ;
System.out.printlnname takes sticks sticks.";
return sticks;
class NimGame
private int sticks;
private Player player;
private Player player;
public NimGameint sticks
this.sticks sticks;
this.player new ComputerComputer;
this.player new HumanHuman;
public void startGame
Player currentPlayer player;
while sticks
System.out.printlnCurrent sticks: sticks;
int takenSticks currentPlayer.makeMovesticks;
sticks takenSticks;
if sticks
System.out.printlnNo moves left. currentPlayer.name wins!";
break;
currentPlayer currentPlayer player player : player;
public class Main
public static void mainString args
Scanner scanner new ScannerSystemin;
int sticks scanner.nextInt;
if argslength
int initialSticks Integer.parseIntargs;
NimGame game new NimGameinitialSticks;
game.startGame;
else
System.out.printlnPlease provide the initial number of sticks as a commandline argument." sticks;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
