<?php
class Rect extends Shape {
private $width = 0;
private $height = 0;
function __construct() {
$this->shapeName = '矩形';
if ($this->validate($_POST["width"], "宽度") & $this->validate($_POST["height"], "高度")) {
$this->width = $_POST["width"];
$this->height = $_POST["height"];
}
}
function area() {
return $this->width * $this->height;
}
function perimoter() {
return 2 * ($this->width + $this->height);
}
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号