Last active
September 2, 2020 02:51
-
-
Save gladson/ca472cbe487276c382a8dffba64eb6a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Triangulo | |
{ | |
private $base; | |
private $altura; | |
private $area; | |
//Getters: | |
public function getAltura() { | |
return $this->altura; | |
} | |
public function getBase() { | |
return $this->base; | |
} | |
public function getArea() { | |
return $this->area; | |
} | |
//Setters: | |
public function setAltura($a) { | |
$this->altura = $a; | |
} | |
public function setBase($b) { | |
$this->base = $b; | |
} | |
public function setArea($ar) { | |
$this->area = $ar; | |
} | |
public function area(){ | |
return ($this->getBase() * $this->getAltura()/2); | |
} | |
public function imprimir(){ | |
print "Altura: ".$this->getAltura()."\n"; | |
print "Base: ".$this->getBase()."\n"; | |
print "Area: ".$this->area()."\n"; | |
} | |
} | |
$area = new Triangulo(); | |
$area->setAltura(6); | |
$area->setBase(3); | |
$area->imprimir(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment