Slide 22
Slide 22 text
protected function execute(InputInterface $input, OutputInterface $output)
{
$dictionary = array(
7 => array('program', 'speaker', 'symfony'),
8 => array('business', 'software', 'hardware'),
9 => array('algorithm', 'framework', 'developer')
);
// Read the input
$length = $input->getArgument('length');
$attempts = $input->getOption('max-attempts');
// Find a word to guess
$words = $dictionary[$length];
$word = $words[array_rand($words)];
// Write the output
$output->writeln(sprintf('The word to guess is %s.', $word));
$output->writeln(sprintf('Max number of attempts is %u.', $attempts));
}