Skip to content

Instantly share code, notes, and snippets.

@gladson
Last active September 2, 2020 02:51
Show Gist options
  • Save gladson/ca472cbe487276c382a8dffba64eb6a2 to your computer and use it in GitHub Desktop.
Save gladson/ca472cbe487276c382a8dffba64eb6a2 to your computer and use it in GitHub Desktop.
<?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