Question: Please help to explain in the below Java code if the move ( take a stick ) should be checked at the time of loading
Please help to explain in the below Java code if the movetake a stick should be checked at the time of loading or can you wait until when the move is to be performed? Both solutions have advantages and disadvantages. Please tell what you prefer, how you did? 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;
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
