当前位置: 首页>>代码示例>>PHP>>正文


PHP Rectangle::getHeight方法代码示例

本文整理汇总了PHP中Rectangle::getHeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Rectangle::getHeight方法的具体用法?PHP Rectangle::getHeight怎么用?PHP Rectangle::getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rectangle的用法示例。


在下文中一共展示了Rectangle::getHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setHeight

        $this->setWidth($width);
    }
    protected function setHeight($height)
    {
        $this->height = $height;
    }
    protected function setWidth($width)
    {
        $this->width = $width;
    }
    protected function getHeight()
    {
        return $this->height;
    }
    protected function getWidth()
    {
        return $this->width;
    }
    public function area()
    {
        return $this->getHeight() * $this->getWidth();
    }
    public function perimeter()
    {
        return $this->getHeight() * 2 + $this->getWidth() * 2;
    }
}
$rectangle = new Rectangle(10, 10);
echo $rectangle->area();
echo $rectangle->getHeight();
echo $rectangle->getWidth();
开发者ID:Reni789,项目名称:Exercises,代码行数:31,代码来源:rectangle.php

示例2: isInner

 /**
  * Определяет, вложен ли текущий прямоугольник в заданный.
  *
  * @param Rectangle $rect
  * @return type
  */
 public function isInner(Rectangle $rect)
 {
     return $this->getTop() >= 0 && $this->getLeft() >= 0 && $this->getBottom() <= $rect->getHeight() && $this->getRight() <= $rect->getWidth();
 }
开发者ID:roman-turchenko,项目名称:morm,代码行数:10,代码来源:Rectangle.php

示例3: Rectangle

<?php

require_once 'rectangle.php';
require_once 'square.php';
$rectangle = new Rectangle(10, 10);
echo $rectangle->area() . PHP_EOL;
echo "The area of a rectangle with height of {$rectangle->getHeight()} and width of {$rectangle->getWidth()} is {$rectangle->area()} " . PHP_EOL;
echo "The perimeter of a rectangle with height of {$rectangle->getHeight} and width of {$rectangle->getWidth()} is {$rectangle->perimeter()} " . PHP_EOL;
// $square = new Square(5);
// echo "The area of a square with height of {$square->height} is {$square->area()} " . PHP_EOL;
// echo "The perimeter of a square with height of {$square->height} is {$square->perimeter()} " . PHP_EOL;
开发者ID:Reni789,项目名称:Exercises,代码行数:11,代码来源:shapes_test.php


注:本文中的Rectangle::getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。