本文整理汇总了PHP中Rectangle::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Rectangle::getValue方法的具体用法?PHP Rectangle::getValue怎么用?PHP Rectangle::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle::getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: surface
{
$this->base = $base;
$this->height = $height;
}
# This might be different for each class of shape, because each Surface is calculated by a different formula ( St = b*h/2 and Sr = b*h)
public abstract function surface();
}
class Triangle extends Shape
{
# s = b*h/2
public function surface()
{
return round($this->base * $this->height / 2, 2);
}
}
class Rectangle extends Shape
{
# s = b*h
public function surface()
{
return round($this->base * $this->height, 2);
}
}
$r = new Rectangle();
$r->getValue(15, 3);
echo $r->surface() . "\n";
# echo 45
$t = new Triangle();
$t->getValue(15, 3);
echo $t->surface() . "\n";
# echo 22.5