-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rectangulo.php
57 lines (49 loc) · 1.11 KB
/
Rectangulo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Created by PhpStorm.
* User: Jordi
* Date: 08/10/2015
* Time: 19:02
*/
namespace Figura;
require_once 'Punto.php';
require_once 'Figura.php';
require_once 'Cuadrado.php';
class Rectangulo extends Cuadrado
{
private $alto;
/**
* @return mixed
*/
public function getAlto()
{
return $this->alto;
}
/**
* @param mixed $alto
*/
public function setAlto($alto)
{
$this->alto = $alto;
}
//constructor de la clase
public function __construct(Punto $origen, $an, $alt){
parent::__construct($origen,$an);
$this->alto=$alt;
}
//metodos de la clase
public function Area(){
return $this->alto*$this->an;
}
public function Perimetro(){
return $this->ancho*2+$this->alto*2;
}
public function Escalar($porc){
parent::Escalar($porc);
$this->alto *=$porc;
}
public function __toString(){
return "Se ha creado figura ".$this->getNumFiguras()." de tipo rectangulo: ".parent::__toString().
", Alto= ".$this->alto/*.", Ancho=".parent::$this->ancho*/;
}
}