Question: Help please to explain and comment the below Java code, what the code does? and also explain @Override. Thanks! class Computer extends Player { public

Help please to explain and comment the below Java code, what the code does? and also explain @Override. Thanks! class Computer extends Player {
public Computer(String name){
super(name);
}
@Override
public int makeMove(int currentSticks){
int sticks =1+(int)(Math.random()*((currentSticks /2)-1+1));
System.out.println(name +" takes "+ sticks +" sticks.");
return sticks;
}
}
class NimGame {
private int sticks;
private Player player1;
private Player player2;
public NimGame(int sticks){
this.sticks = sticks;
this.player1= new Computer("Computer");
this.player2= new Human("Human");
}

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!