Advertisement
stamsarg

Untitled

Nov 29th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. class Food
  2. {
  3. public $name;
  4. public $calories;
  5. public $isHealthy;
  6. public $eatHowMuchPerWeek;
  7. public $delicious;
  8. public function _construct($name, $calories, $isHealthy, $eatHowMuchPerWeek, $delicious)
  9. {
  10. $this->name = $name;
  11. $this->calories = $calories;
  12. $this->isHealthy = $isHealthy;
  13. $this->eatHowMuchPerWeek = $eatHowMuchPerWeek;
  14. $this->delicious = $delicious;
  15. }
  16. public function info()
  17. {
  18. 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;
  19. }
  20. }
  21. class Bacon extends Food
  22. {
  23. public $delicious = "ALWAYS";
  24. public $name;
  25. public $calories;
  26. public $isHealthy;
  27. public $eatHowMuchPerWeek;
  28. public function _construct($name, $calories, $isHealthy, $eatHowMuchPerWeek)
  29. {
  30. $this->name = $name;
  31. $this->calories = $calories;
  32. $this->isHealthy = $isHealthy;
  33. $this->eatHowMuchPerWeek = $eatHowMuchPerWeek;
  34. }
  35. }
  36. $myBacon = new Bacon("bacon", 300, true, 3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement