Created
February 6, 2022 12:40
-
-
Save osteel/816b97705eec486d5322defcc9c29936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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