Beispiel #1
0
    $output = new standardOutput();
    $output->renderStandardView();
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $universe = new Universe();
    $basketsContent = $universe->displayOrdinaryBaskets();
    if (preg_match('/^[0-9]{1,3}$/', $_POST['usersBasketAmount'])) {
        if ($_POST['usersBasketAmount'] >= 1 and $_POST['usersBasketAmount'] <= 100) {
            $userBasketContent = $universe->generateUserBasket($_POST['usersBasketAmount']);
        } else {
            $error = true;
        }
    } else {
        if ($_POST['usersBasketAmount'] != '') {
            $error = true;
        } else {
            $userBasketContent = $universe->generateUserBasket();
        }
    }
    if (!isset($error)) {
        $taskB = $universe->checkTaskB();
        $taskC = $universe->checkTaskC();
        $output = new resultOutput();
        $output->renderResultView($basketsContent, $userBasketContent, $taskB, $taskC);
    } else {
        $output = new standardOutput();
        $output->renderStandardView($error);
    }
} else {
    $output = new standardOutput();
    $output->renderStandardView();
}