Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Food
- {
- public $name;
- public $calories;
- public $isHealthy;
- public $eatHowMuchPerWeek;
- public $delicious;
- public function _construct($name, $calories, $isHealthy, $eatHowMuchPerWeek, $delicious)
- {
- $this->name = $name;
- $this->calories = $calories;
- $this->isHealthy = $isHealthy;
- $this->eatHowMuchPerWeek = $eatHowMuchPerWeek;
- $this->delicious = $delicious;
- }
- public function info()
- {
- echo "Hello. I am " . $this->name . ". I can give up to " . $this->calories . " calories. Am I healthy? " . $this->isHealthy . ". You should eat " . $this->eatHowMuchPerWeek . " pieces of me per week. Am I delicious? " . $this->delicious;
- }
- }
- class Bacon extends Food
- {
- public $delicious = "ALWAYS";
- public $name;
- public $calories;
- public $isHealthy;
- public $eatHowMuchPerWeek;
- public function _construct($name, $calories, $isHealthy, $eatHowMuchPerWeek)
- {
- $this->name = $name;
- $this->calories = $calories;
- $this->isHealthy = $isHealthy;
- $this->eatHowMuchPerWeek = $eatHowMuchPerWeek;
- }
- }
- $myBacon = new Bacon("bacon", 300, true, 3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement