name = $name;
$this->height = $height;
$this->weight = $weight;
}
public function bmi() {
return $this->weight / (pow($this->height / 100, 2));
}
public function phanloai(){
$bmi = $this->bmi();
if ($bmi < 18.5) {
return "Thieu can";
} elseif ($bmi >= 18.5 && $bmi < 25) {
return "Binh thuong";
} elseif ($bmi >= 25 ){
return "Thua can";
}
}
}
class Student extends People {
public $id;
public $score;
public function __construct($name, $height, $weight, $id, $score) {
parent::__construct($name, $height, $weight);
$this->id = $id;
$this->score = $score;
}
public function phanloaitostring() {
return "BMI cua ". $this->name ." la: " . $this->phanloai() . "
";
}
public function xephang(){
if( $this->score >= 90 ){
return "A";
} elseif( $this->score >= 80 ){
return "B";
} elseif( $this->score >= 70 ){
return "C";
} elseif( $this->score >= 60 ){
return "D";
} elseif( $this->score >= 50 ){
return "E";
}else{
return "F";
}
}
}
$xuan = new People("Xuan", 150, 44);
$quynh = new Student("Quynh", 152, 45, 1, 90);
echo $quynh->phanloaitostring();
echo "ID cua ". $quynh->name ." la: " . $quynh->id . "
";
echo "KQ cua ". $quynh->name ." la: " . $quynh->xephang() . "
";
// echo "BMI của ". $xuan->name ." là: " . $xuan->phanloai() . "
";