diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/php/vandresca.php" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/php/vandresca.php" new file mode 100644 index 0000000000..54cc51cc25 --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/php/vandresca.php" @@ -0,0 +1,75 @@ +rules = $rules; + } + + public function generate(int $n): array { + $result = []; + for ($i = 1; $i <= $n; $i++) { + $value = ''; + foreach ($this->rules as $rule) { + if ($rule->check($i)) { + $value .= $rule->getValue(); + } + } + + $result[] = ($value !== '') ? $value : (string)$i; + } + return $result; + } + + // Muestra los resultados en la consola + public function printResult(int $n): void { + $result = $this->generate($n); + foreach ($result as $item) { + echo $item . "\n"; + } + } +} + + +echo "Reto #0: EL FAMOSO \"FIZZ BUZZ\"\n"; +$fizzBuzz = new FizzBuzz([new FizzRule(), new BuzzRule()]); +$fizzBuzz->printResult(100); + +?> \ No newline at end of file