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


PHP Rectangle::area方法代码示例

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


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

示例1: areaVerifier

 function areaVerifier(Rectangle $r)
 {
     $r->setWidth(5);
     $r->setHeight(4);
     if ($r->area() != 20) {
         return false;
     }
     return true;
 }
开发者ID:erikfig,项目名称:curso-php-moderno-turma-2,代码行数:9,代码来源:Client.php

示例2: Rectangle

<?php

require_once "rectangle.php";
require_once "square.php";
$rect1 = new Rectangle(2, 7);
echo $rect1->area();
echo "\n";
echo $rect1->perimeter();
echo "\n";
$rect2 = new Rectangle(3, 4);
echo $rect2->area();
echo "\n";
echo $rect2->perimeter();
echo "\n";
$square1 = new Square(2);
echo $square1->area();
echo "\n";
echo $square1->perimeter();
echo "\n";
$square1 = new Square(3);
echo $square1->area();
echo "\n";
echo $square1->perimeter();
echo "\n";
?>
 ?>
开发者ID:wbreiding,项目名称:Codeup_Exercises,代码行数:26,代码来源:shapes_test.php

示例3: Rectangle

<?php

require_once 'square.php';
$rectangle = new Rectangle(20, 40);
echo 'The area of this rectangle is ' . $rectangle->area() . PHP_EOL;
$square = new Square(20);
echo 'The perimeter of this square is ' . $square->perimeter() . PHP_EOL;
开发者ID:Craig240z,项目名称:CodeUp-Web-Exercises,代码行数:7,代码来源:shapes_test.php

示例4: 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

示例5: Rectangle

<!-- shapes_test.php -->
<!-- 9.2.1 -->
<?php 
require_once 'square.php';
// use this to run rectangle
$shape = new Rectangle(11, 39);
echo 'Area of Rectangle = ' . $shape->area() . PHP_EOL;
$square = new Square(2, 2);
echo 'Perimiter of square = ' . $square->Perimeter();
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>shapes_test.php</title>
  </head>
  <body>
    <h1> shapes_test.php | 9.2.1</h1>
    <script>
      console.log("INCLUDED: shapes_test.php")
    </script>
  </body>
</html>
开发者ID:burneyburney,项目名称:codeup.dev,代码行数:23,代码来源:shapes_test.php

示例6: Rectangle

<?php

require_once 'rectangle.php';
require_once 'square.php';
// Test your new class by creating an instance of Rectangle with various heights and widths.
$rekt_one = new Rectangle(7, 14);
$rekt_two = new Rectangle('5', '10');
$rekt_three = new Rectangle(33.33, 66.66);
$square_one = new Square(4);
// Calling the area method should correctly display the product of height and width.
var_dump($rekt_one->area());
var_dump($rekt_one->perimeter());
// var_dump($rekt_two->area());
// var_dump($rekt_three->area());
var_dump($square_one->perimeter());
var_dump($square_one->area());
开发者ID:j-beere,项目名称:Codeup_Exercises,代码行数:16,代码来源:shapes_test.php

示例7: Rectangle

<?php

require_once "rectangle.php";
require_once "square.php";
$rectangle = new Rectangle(4, 8);
$square = new Square(41);
echo $rectangle->area() . PHP_EOL;
echo $rectangle->perimeter() . PHP_EOL;
echo $square->area() . PHP_EOL;
echo $square->perimeter() . PHP_EOL;
开发者ID:sjmrt,项目名称:codeup-web-exercises,代码行数:10,代码来源:shapes_test.php

示例8: Square

<?php

require_once "rectangle.php";
require_once "square.php";
$squr = new Square(10, 30);
$area = $squr->equalarea() . " sq.";
echo $area . PHP_EOL;
$perimeter = $squr->perimeter() . " long.";
echo $perimeter . PHP_EOL;
$rect = new Rectangle(10, 30);
$area = $rect->area() . " sq.";
echo $area . PHP_EOL;
$perimeter = $rect->perimeter() . " long.";
echo $perimeter . PHP_EOL;
开发者ID:Yeasayer,项目名称:codeup_web_exercises,代码行数:14,代码来源:shapes_area.php

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