par
djun » 21 févr. 2012, 22:19
Bonjour,
Mes getters ne veulent pas etre afficher:
Code : Tout sélectionner
nom:
genre:
travaille que chef entreprise
va prendre une bierre
nom:
genre:
travaille en tant que sécrétaire
va faire du shopping entre fille
Qui peut trouver mon erreur:
<?php
abstract class Humain
{
protected $nom ;
protected $genre ;
public function getNom()
{
return $this->nom ;
}
public function setNom($x)
{
$this->nom = $x ;
}
public function getGenre()
{
return $this->genre ;
}
abstract function travailler() ;
abstract function divertir() ;
}
class Homme extends Humain
{
public function __construction($x)
{
$this->genre = 'M' ;
$this->nom = $x ;
}
public function travailler()
{
echo $this->nom ,' travaille que chef entreprise' ;
}
public function divertir()
{
echo $this->nom ,' va prendre une bierre' ;
}
}
class Femme extends Humain
{
public function __construction($x)
{
$this->genre = 'F' ;
$this->nom = $x ;
}
public function travailler()
{
echo $this->nom ,' travaille en tant que sécrétaire' ;
}
public function divertir()
{
echo $this->nom ,' va faire du shopping entre fille' ;
}
}
$Juliette = new Femme('Juliette') ;
$Alain = new Homme('Alain') ;
$format1 = 'nom : %s' ;
$format2 = 'Genre: %s' ;
echo 'nom: ', $Alain->getNom();
echo '<br/>' ;
echo 'genre: ', $Alain->getGenre() ;
echo '<br/>' ;
$Alain->travailler() ;
echo '<br/>' ;
$Alain->divertir() ;
echo '<br/>' ;
echo '<br/>' ;
echo 'nom: ', $Juliette->getNom() ;
echo '<br/>' ;
echo 'genre: ', $Juliette->getGenre() ;
echo '<br/>' ;
$Juliette->travailler() ;
echo '<br/>' ;
$Juliette->divertir() ;
?>
Bonjour,
Mes getters ne veulent pas etre afficher:
[code]nom:
genre:
travaille que chef entreprise
va prendre une bierre
nom:
genre:
travaille en tant que sécrétaire
va faire du shopping entre fille[/code]
Qui peut trouver mon erreur:
[php]<?php
abstract class Humain
{
protected $nom ;
protected $genre ;
public function getNom()
{
return $this->nom ;
}
public function setNom($x)
{
$this->nom = $x ;
}
public function getGenre()
{
return $this->genre ;
}
abstract function travailler() ;
abstract function divertir() ;
}
class Homme extends Humain
{
public function __construction($x)
{
$this->genre = 'M' ;
$this->nom = $x ;
}
public function travailler()
{
echo $this->nom ,' travaille que chef entreprise' ;
}
public function divertir()
{
echo $this->nom ,' va prendre une bierre' ;
}
}
class Femme extends Humain
{
public function __construction($x)
{
$this->genre = 'F' ;
$this->nom = $x ;
}
public function travailler()
{
echo $this->nom ,' travaille en tant que sécrétaire' ;
}
public function divertir()
{
echo $this->nom ,' va faire du shopping entre fille' ;
}
}
$Juliette = new Femme('Juliette') ;
$Alain = new Homme('Alain') ;
$format1 = 'nom : %s' ;
$format2 = 'Genre: %s' ;
echo 'nom: ', $Alain->getNom();
echo '<br/>' ;
echo 'genre: ', $Alain->getGenre() ;
echo '<br/>' ;
$Alain->travailler() ;
echo '<br/>' ;
$Alain->divertir() ;
echo '<br/>' ;
echo '<br/>' ;
echo 'nom: ', $Juliette->getNom() ;
echo '<br/>' ;
echo 'genre: ', $Juliette->getGenre() ;
echo '<br/>' ;
$Juliette->travailler() ;
echo '<br/>' ;
$Juliette->divertir() ;
?>
[/php]