<?php
class Dog {
private $name;
private $weight;
private $height;
public function __construct($name, $weight,$height){
$this->name = $name;
$this->weight = $weight;
$this->height = $height;
}
public function introduce(){
$this->introduce_name();
$this->introduce_weight();
$this->introduce_height();
}
private function introduce_name(){
echo '僕の名前は'. $this->name. 'だワン!'.PHP_EOL;
}
private function introduce_weight(){
echo '僕の体重は'. $this->weight.'kgだワン!'.PHP_EOL;
echo ($this->weight < 10 ? '小型犬だワン!' : '中型犬以上だワン!').PHP_EOL;
}
private function introduce_height(){
echo '僕の体長は'. $this->height.'cmだワン!'.PHP_EOL;
}
}
$hati = new Dog('ハチ', 9,70);
$hati->introduce();