Skip to content

Instantly share code, notes, and snippets.

@osteel
Created February 6, 2022 12:40
Show Gist options
  • Save osteel/816b97705eec486d5322defcc9c29936 to your computer and use it in GitHub Desktop.
Save osteel/816b97705eec486d5322defcc9c29936 to your computer and use it in GitHub Desktop.
$term1 = rand(1, 10);
$term2 = rand(1, 10);
$result = $term1 + $term2;
$io = new SymfonyStyle($input, $output);
$answer = (int) $io->ask(sprintf('What is %s + %s?', $term1, $term2));
if ($answer === $result) {
$io->success('Well done!');
} else {
$io->error(sprintf('Aww, so close. The answer was %s', $result));
}
if ($io->confirm('Play again?')) {
return $this->execute($input, $output);
}
return Command::SUCCESS;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment