nom = $nomClasse; $this->jours = []; foreach (self::$joursSemaine as $jour) $this->jours[$jour] = [0, 0]; } public function setLundi(int $matin, int $aprem = 0) {$this->jours["lundi"] = [$matin, $aprem];} public function setMardi(int $matin, int $aprem = 0) {$this->jours["mardi"] = [$matin, $aprem];} public function setMercredi(int $matin, int $aprem = 0) {$this->jours["mercredi"] = [$matin, $aprem];} public function setJeudi(int $matin, int $aprem = 0) {$this->jours["jeudi"] = [$matin, $aprem];} public function setVendredi(int $matin, int $aprem = 0) {$this->jours["vendredi"] = [$matin, $aprem];} public function setSamedi(int $matin, int $aprem = 0) {$this->jours["samedi"] = [$matin, $aprem];} public function setDimanche(int $matin, int $aprem = 0) {$this->jours["dimanche"] = [$matin, $aprem];} public function setDayByNb(int $day, int $matin, int $aprem = 0 ){ switch ($day) { case 1: $this->setLundi($matin, $aprem);break; case 2: $this->setMardi($matin, $aprem);break; case 3: $this->setMercredi($matin, $aprem);break; case 4: $this->setJeudi($matin, $aprem);break; case 5: $this->setVendredi($matin, $aprem);break; case 6: $this->setSamedi($matin, $aprem);break; case 7: $this->setDimanche($matin, $aprem);break; } } public function getNom() : string {return $this->nom;} public function toString() : string { $texte = ""; $x = 0; $td = 14; if (!$this->estVide()){ foreach (GestionSemaine::$joursSemaine as $jour) { if ($td <= 0){break;} if ($x <= 0){ if ($this->jours[$jour][0] == 0 && $this->jours[$jour][1] == 0) { $texte = $texte . ""; $td -= 2; }else { if ($this->jours[$jour][0] != 0) {$x = $this->jours[$jour][0]; $texte = $texte . "
o
"; $td -= $this->jours[$jour][0]; } elseif ($this->jours[$jour][1] != 0) { $texte = $texte . ""; $texte = $texte . "
o
"; $x = $this->jours[$jour][1]-1; $td -= ($this->jours[$jour][1]+1); } } } if ($x-2 >= 0) { $x = $x - 2; } elseif ($x-1 == 0) { $x = $x - 1; $texte = $texte . ""; } } } return $texte; } public function estVide() { $somme = 0; foreach (self::$joursSemaine as $jour) {$somme = $somme + $this->jours[$jour][0] + $this->jours[$jour][1];} return $somme == 0; } }