| Server IP : 109.234.162.214 / Your IP : 216.73.216.222 Web Server : Apache System : Linux servd162214.srv.odns.fr 4.18.0-372.26.1.lve.1.el8.x86_64 #1 SMP Fri Sep 16 14:08:19 EDT 2022 x86_64 User : carpe ( 1178) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/carpe/public_html/MuletVsFondation/ |
Upload File : |
<?php
class Personne{
protected $nom;
protected $prenom;
protected $age;
protected $metier;
protected $classe;
public function sePresenter(){
echo "Je m'appelle {$this->prenom} {$this->nom}, j'ai {$this->age} ans, je suis un.e {$this->metier} .";
}
public function achat(){
echo "{$this->prenom} {$this->nom} : ";
if($this->classe == 'Mentaliste'){
echo "Bonjour, je voudrais des rations s'il vous plait.";
}
if($this->classe == 'Client'){
echo "Bonjour, j'vais vous prendre 6 baguettes.";
}
}
public function __construct($n,$p,$a,$m,$c){
$this->nom = $n;
$this->prenom = $p;
$this->age = $a;
$this->metier = $m;
$this->classe = $c;
}
public function toArray() {
return [
'nom' => $this->nom,
'prenom' => $this->prenom,
'age' => $this->age,
'metier' => $this->metier,
'classe' => $this->classe,
];
}
}
$personnes = [
new Personne("Wils", "Tony", 42,"Technicien","Client"),
new Personne("Abrams","Aby",25,"Agent dentretien","Mentaliste"),
new Personne("Losons", "Joem", 42,"Agent dentretien","Client"),
new Personne("Osh","Loan",25,"Agent dentretien","Mentaliste"),
new Personne("Asty", "Ely", 42,"Technicien","Client"),
new Personne("Popopom","John",25,"Agent dentretien","Mentaliste"),
new Personne("Lincoln","Stephen",25,"Agent dentretien","Mentaliste"),
new Personne("Grimes", "Eric", 42,"Technicien","Client"),
new Personne("White","Walter",25,"Pilote","Mentaliste"),
new Personne("Ash", "Steve", 42,"Technicien","Client"),
new Personne("Blury","Ash",25,"Pilote","Mentaliste"),
];
class Operateur extends Personne{
protected $nom;
protected $prenom;
protected $age;
protected $metier;
protected $classe;
public function __construct($n,$p,$a,$m,$c){
parent::__construct($n,$p,$a,$m,$c);
}
public function reparation($vaisseau){
if($this->metier == "Technicien"){
//echo "Je suis {$this->metier}, je m'appel {$this->nom}";
if($vaisseau->etat_technique < 100){
$vaisseau->etat_technique += 10;
echo "L'état technique du vaisseau {$vaisseau->nom} s'est amélioré de 10% .<br/>";
echo "Son état est désormais de {$vaisseau->etat_technique}";
}
}else if($this->metier =="Agent dentretien"){
//echo "Je suis {$this->metier}";
}
}
}
class Mentaliste extends Personne{
protected $nom;
protected $prenom;
protected $age;
protected $metier;
protected $classe;
public function __construct($n,$p,$a,$m,$c){
parent::__construct($n,$p,$a,$m,$c);
}
public function agir($perso){
echo "perso";
}
}
//$o1 = new Operateur('Carpe','Plume',19,'Medecin','Client');
//echo $o1->reparation();
?>