Untitled
unknown
php
a year ago
1.0 kB
4
Indexable
<?php class Rectangle { protected int $width; protected int $height; public function setWidth(int $width): void { $this->width = $width; } public function setHeight(int $height): void { $this->height = $height; } public function calculateArea(): int { returh $this->width * $this->height; } } class Square extends Rectangle { protected int $width; protected int $height; public function setWidth(int $width): void { $this->width = $width; $this->height = $width; } public function setHeight(int $height): void { $this->height = $height; $this->height = $height; } } class RectangleTest extends TestCase { public function testCalculateArea() { // $shape = new Rectangle(); $shape = new Square(); $shape->setWidth(10); $shape->setHeight(2); $this->assertEquals($shape->calculateArea(), 20); } }
Editor is loading...
Leave a Comment