learning about Objects. I’m suppose to include 2 methods: talk (bark) and move(run, walk). Would I use constructors? This is what I am trying to do but getting the following error message: Fatal error: Cannot redeclare pet::__constructor() on line 43. What does this mean?
I’m suppose to then call the talk and move methods.
[php]<?php
class pet{
private $type;
private $name;
private $breed;
private $color;
private $talk;
private $move;
//set
public function setType($x){
$this->type=$x;
}
public function setName($x){
$this->name=$x;
}
public function setBreed($x){
$this->breed=$x;
}
public function setColor($x){
$this->color=$x;
}
//get
public function getType(){
return $this->type;
}
public function getName(){
return $this->name;
}
public function getBreed(){
return $this->breed;
}
public function getColor(){
return $this->color;
}
public function __constructor ($bark){
echo "$name can you $talk?";
}
public function __constructor($run){
echo " run!";
}
}
?>
$PetObject = new pet();
$PetObject->setType("Dog ");
echo $PetObject->getType();
$PetObject->setName("Fido ");
echo $PetObject->getName();
$PetObject->setBreed("German Shepherd ");
echo $PetObject->getBreed();
$PetObject->setColor(“yellow”);
echo $PetObject->getColor();
?>
[/php]