Skip to content

Commit

Permalink
Updating files
Browse files Browse the repository at this point in the history
  • Loading branch information
fidilly committed Apr 7, 2019
1 parent 6715e07 commit 30ff9c9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/Games/Calc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
function getGameData()
{
$generateData = function () {
$questionOperandOne = rand(0, 20);
$questionOperandTwo = rand(0, 20);
$questionOperator = OPERATORS[array_rand(OPERATORS)];
switch ($questionOperator) {
$operandOne = rand(0, 20);
$operandTwo = rand(0, 20);
$operator = OPERATORS[array_rand(OPERATORS)];
switch ($operator) {
case '+':
$correctAnswer = $questionOperandOne + $questionOperandTwo;
$correctAnswer = $operandOne + $operandTwo;
break;
case '-':
$correctAnswer = $questionOperandOne - $questionOperandTwo;
$correctAnswer = $operandOne - $operandTwo;
break;
case '*':
$correctAnswer = $questionOperandOne * $questionOperandTwo;
$correctAnswer = $operandOne * $operandTwo;
break;
}
$question = "$questionOperandOne $questionOperator $questionOperandTwo";
$question = "$operandOne $operator $operandTwo";
return [$question, $correctAnswer];
};

Expand Down
8 changes: 4 additions & 4 deletions src/Games/Gcd.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
function getGameData()
{
$generateData = function () {
$questionOperandOne = rand(1, 100);
$questionOperandTwo = rand(1, 100);
$correctAnswer = getGcd($questionOperandOne, $questionOperandTwo);
$question = "$questionOperandOne $questionOperandTwo";
$operandOne = rand(1, 100);
$operandTwo = rand(1, 100);
$correctAnswer = getGcd($operandOne, $operandTwo);
$question = "$operandOne $operandTwo";
return [$question, $correctAnswer];
};

Expand Down
11 changes: 6 additions & 5 deletions src/Games/Progression.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ function getGameData()
$generateData = function () {
$startValue = rand(1, 10);
$stepValue = rand(1, 10);
$progression = [];

for ($i = 0; $i < PROGRESSION_LENGTH; $i++) {
$progressionNumbers[] = $startValue + $stepValue * $i;
$progression[] = $startValue + $stepValue * $i;
}

$indexToHide = array_rand($progressionNumbers);
$correctAnswer = $progressionNumbers[$indexToHide];
$progressionNumbers[$indexToHide] = "..";
$question = implode(" ", $progressionNumbers);
$indexToHide = array_rand($progression);
$correctAnswer = $progression[$indexToHide];
$progression[$indexToHide] = "..";
$question = implode(" ", $progression);

return [$question, $correctAnswer];
};
Expand Down

0 comments on commit 30ff9c9

Please sign in to comment.