From ca99c45b5e10843f2edc7b9af3d2c4ae99a2f6f9 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Wed, 16 Nov 2022 09:46:50 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Correction=20de=20la=20classe=20M=C3=A9tier?= =?UTF-8?q?=20Enigme=20et=20mise=20en=20place=20de=202=20constructeurs=20d?= =?UTF-8?q?iff=C3=A9rents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/DetailPartieGateway.php | 52 ---------- WEB/Model/DetailPartie.php | 125 ------------------------- WEB/Model/Enigme.php | 9 +- WEB/Model/Partie.php | 21 +++++ 4 files changed, 25 insertions(+), 182 deletions(-) delete mode 100644 WEB/Controller/DetailPartieGateway.php delete mode 100644 WEB/Model/DetailPartie.php diff --git a/WEB/Controller/DetailPartieGateway.php b/WEB/Controller/DetailPartieGateway.php deleted file mode 100644 index 2e2f8102..00000000 --- a/WEB/Controller/DetailPartieGateway.php +++ /dev/null @@ -1,52 +0,0 @@ -con = $con; - } - - /** - * @param Connection $con - */ - public function setCon(Connection $con): void - { - $this->con = $con; - } - - public function insert(DetailPartie $detailPartie) - { - $query="INSERT INTO DetailPartie VALUES (:idDetailPartie,:joueur,:partie,:enigme,:pointsObtenus,:classement)"; - $this->con->executeQuery($query,array( - 'idDetailPartie' => array($detailPartie->getIdDetailPartie(),PDO::PARAM_STR), - 'joueur' => array($detailPartie->getJoueur(),PDO::PARAM_STR), - 'partie' => array($detailPartie->getPartie(),PDO::PARAM_STR), - 'enigme' => array($detailPartie->getEnigme(),PDO::PARAM_STR), - 'pointsObtenus' => array($detailPartie->getPointsObtenus(),PDO::PARAM_INT), - 'classement' => array($detailPartie->getClassement(),PDO::PARAM_INT) - )); - } - public function delete(string $partie){ - $query="DELETE * FROM DetailPartie WHERE partie=:partie"; - $this->con->executeQuery($query,array( - 'partie' => array($partie,PDO::PARAM_STR) - )); - } - public function showAll(){ - $query="SELECT * FROM DetailPartie"; - $this->con->executeQuery($query); - $results=$this->con->getResults(); - foreach($results as $row) - { - $row['idDetailPartie']; - } - } - - -} \ No newline at end of file diff --git a/WEB/Model/DetailPartie.php b/WEB/Model/DetailPartie.php deleted file mode 100644 index b80095cd..00000000 --- a/WEB/Model/DetailPartie.php +++ /dev/null @@ -1,125 +0,0 @@ -idDetailPartie = $idDetailPartie; - $this->joueur = $joueur; - $this->partie = $partie; - $this->enigme = $enigme; - $this->pointsObtenus = $pointsObtenus; - $this->classement = $classement; - } - - /** - * @return string - */ - public function getIdDetailPartie(): string - { - return $this->idDetailPartie; - } - - /** - * @param string $idDetailPartie - */ - public function setIdDetailPartie(string $idDetailPartie): void - { - $this->idDetailPartie = $idDetailPartie; - } - - /** - * @return string - */ - public function getJoueur(): string - { - return $this->joueur; - } - - /** - * @param string $joueur - */ - public function setJoueur(string $joueur): void - { - $this->joueur = $joueur; - } - - /** - * @return string - */ - public function getPartie(): string - { - return $this->partie; - } - - /** - * @param string $partie - */ - public function setPartie(string $partie): void - { - $this->partie = $partie; - } - - /** - * @return string - */ - public function getEnigme(): string - { - return $this->enigme; - } - - /** - * @param string $enigme - */ - public function setEnigme(string $enigme): void - { - $this->enigme = $enigme; - } - - /** - * @return int - */ - public function getPointsObtenus(): int - { - return $this->pointsObtenus; - } - - /** - * @param int $pointsObtenus - */ - public function setPointsObtenus(int $pointsObtenus): void - { - $this->pointsObtenus = $pointsObtenus; - } - - /** - * @return int - */ - public function getClassement(): int - { - return $this->classement; - } - - /** - * @param int $classement - */ - public function setClassement(int $classement): void - { - $this->classement = $classement; - } -} \ No newline at end of file diff --git a/WEB/Model/Enigme.php b/WEB/Model/Enigme.php index 40163a39..56189534 100644 --- a/WEB/Model/Enigme.php +++ b/WEB/Model/Enigme.php @@ -9,7 +9,7 @@ class Enigme private string $rappel; private string $solution; private string $test; - private float $tempsDeResolution; + private int $tempsDeResolution; /** * @param string $idEnigme @@ -21,7 +21,7 @@ class Enigme * @param string $test * @param int $tempsDeResolution */ - public function __construct(string $idEnigme, string $admin, string $enonce, string $aide, string $rappel, string $solution, string $test, float $tempsDeResolution) + public function __construct(string $idEnigme, string $admin, string $enonce, string $aide, string $rappel, string $solution, string $test, int $tempsDeResolution) { $this->idEnigme = $idEnigme; $this->admin = $admin; @@ -32,7 +32,6 @@ class Enigme $this->test = $test; $this->tempsDeResolution = $tempsDeResolution; } - /** * @return string */ @@ -148,7 +147,7 @@ class Enigme /** * @return int */ - public function getTempsDeResolution(): float + public function getTempsDeResolution(): int { return $this->tempsDeResolution; } @@ -156,7 +155,7 @@ class Enigme /** * @param int $tempsDeResolution */ - public function setTempsDeResolution(float $tempsDeResolution): void + public function setTempsDeResolution(int $tempsDeResolution): void { $this->tempsDeResolution = $tempsDeResolution; } diff --git a/WEB/Model/Partie.php b/WEB/Model/Partie.php index baf996df..11375902 100644 --- a/WEB/Model/Partie.php +++ b/WEB/Model/Partie.php @@ -3,13 +3,16 @@ class Partie { private string $idPartie; + private date $datePartie; /** * @param string $idPartie + * @param date $datePartie */ public function __construct(string $idPartie) { $this->idPartie = $idPartie; + $this->datePartie = getdate(NULL); } /** @@ -27,4 +30,22 @@ class Partie { $this->idPartie = $idPartie; } + + /** + * @return date + */ + public function getDatePartie(): date + { + return $this->datePartie; + } + + /** + * @param date $datePartie + */ + public function setDatePartie(date $datePartie): void + { + $this->datePartie = $datePartie; + } + + } \ No newline at end of file From c6f75c110f56c85460061ffe04dbad407567fef7 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Wed, 16 Nov 2022 09:47:04 +0100 Subject: [PATCH 2/2] Corrction de la classe Enigme --- WEB/Model/Enigme.php | 50 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/WEB/Model/Enigme.php b/WEB/Model/Enigme.php index 56189534..d14528ec 100644 --- a/WEB/Model/Enigme.php +++ b/WEB/Model/Enigme.php @@ -3,7 +3,6 @@ class Enigme { private string $idEnigme; - private string $admin; private string $enonce; private string $aide; private string $rappel; @@ -13,7 +12,6 @@ class Enigme /** * @param string $idEnigme - * @param string $admin * @param string $enonce * @param string $aide * @param string $rappel @@ -21,17 +19,31 @@ class Enigme * @param string $test * @param int $tempsDeResolution */ - public function __construct(string $idEnigme, string $admin, string $enonce, string $aide, string $rappel, string $solution, string $test, int $tempsDeResolution) + public function __construct(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test, int $tempsDeResolution) { - $this->idEnigme = $idEnigme; - $this->admin = $admin; - $this->enonce = $enonce; - $this->aide = $aide; - $this->rappel = $rappel; - $this->solution = $solution; - $this->test = $test; - $this->tempsDeResolution = $tempsDeResolution; + $arguments=func_get_args(); + $index=func_num_args(); + if(method_exists($this,$function='__construct'.$index)); + call_user_func(array(array($this,$function),$arguments)); + } + + public function __constructMulti(string $idEnigme, string $enonce, string $solution, string $test, int $tempsDeResolution){ + $this->idEnigme=$idEnigme; + $this->enonce=$enonce; + $this->solution=$solution; + $this->test=$test; + $this->tempsDeResolution=$tempsDeResolution; } + + public function __constructSolo(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test){ + $this->idEnigme=$idEnigme; + $this->enonce=$enonce; + $this->aide=$aide; + $this->rappel=$rappel; + $this->solution=$solution; + $this->test=$test; + } + /** * @return string */ @@ -48,22 +60,6 @@ class Enigme $this->idEnigme = $idEnigme; } - /** - * @return string - */ - public function getAdmin(): string - { - return $this->admin; - } - - /** - * @param string $admin - */ - public function setAdmin(string $admin): void - { - $this->admin = $admin; - } - /** * @return string */