#recursion token generator, help on the recursion part at 10:30pm
5 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @drowsy berry! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
public boolean play(int tokens) {
if (tokens == this.target) {
return true;
}
if (this.remainingTurns == 0) {
return false;
}
Scanner scanner; // accept user input, limit options based on current token count, reduce turns by one, etc
int newTokenCount; // the resulting tokens after applying the user’s choice
play(newTokenCount); // <—— this is where the recursion happens, effectively forming a “play” loop
}
Sorry if there’s formatting errors, typing on my phone.
This should get you in the right direction. Give it a go.