<?php
class Quest
{
public $text ;
public $points ;
public $answers ;
public $correctAnswer ;
function __construct( $text , $points , $answers , $correctAnswer )
{
$this -> text = $text ;
$this -> points = $points ;
$this -> answers = $answers ;
$this -> correctAnswer = $correctAnswer ;
}
function printQ( ) {
$i = 1 ;
echo "$i ) $this->text $k \n " ;
foreach ( $this -> answers as $letter => $answer ) {
echo "$letter . $answer \n " ;
$i ++;
}
}
function checkQ( $ans ) {
for ( $j = 0 ; $j < count ( $ans ) ; $j ++ ) { if ( $this -> correctAnswer == $ans [ $j ] ) {
echo "Вопрос $this->text Дан ответ $ans [$j ] - Ответ правильный\n " ;
}
if ( $this -> correctAnswer != $ans [ $j ] ) {
echo "Вопрос $this->text Дан ответ $ans [$j ] - Ответ не правильный, правильный ответ $this->correctAnswer \n " ;
}
return $this -> points ;
}
}
}
$q1 = new Quest
( "Столица Норвегии" , 10 , array ( 'a' => 'Прага' , 'b' => 'Осло' , 'c' => 'Берлин' , 'd' => 'Стокгольм' ) , "b" ) ; $q2 = new Quest
( "Год начала второй мировой войны" , 5 , array ( 'a' => '1941' , 'b' => '1912' , 'c' => '1939' , 'd' => '1895' ) , "b" ) ; $q3 = new Quest
( "Кто создал теорию относительности" , 10 , array ( 'a' => 'Ван Дамм' , 'b' => 'Резерфорд' , 'c' => 'Максвелл' , 'd' => 'Эйнштейн' ) , "d" ) ;
foreach ( $que as $que1 ) {
$totalPoints += $que1 -> checkQ ( $ans ) ;
}
echo $totalPoints ;
// your code goes here
PD9waHAKY2xhc3MgUXVlc3QgCnsKICAgcHVibGljICR0ZXh0OwogICBwdWJsaWMgJHBvaW50czsKICAgcHVibGljICRhbnN3ZXJzOwogICBwdWJsaWMgJGNvcnJlY3RBbnN3ZXI7CiAgIApmdW5jdGlvbiBfX2NvbnN0cnVjdCgkdGV4dCwkcG9pbnRzLCRhbnN3ZXJzLCRjb3JyZWN0QW5zd2VyKSAgCnsKICAgICR0aGlzLT50ZXh0ICAgICAgICAgICAgID0kdGV4dDsKICAg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