You are on page 1of 6

Ecua1.php <?php require_once("opera.

php"); class Ecua1 extends Opera{ public function calcula($a,$b,$c){ $this->suma($a,$b); $this->suma($this->rs,$c); echo "<br>el resultado de ecuacion 1 es ".$this->rs; } } ?>

Ecua2.php

<?php require_once("opera.php"); class Ecua2 extends Opera{ public function calcula($a,$b,$c){ $this->suma($a,$b); $this->resta($this->rs,$c); echo "<br>el resultado de ecuacion 2 es ".$this->rr; } } ?>

Ecua3.php <?php require_once("opera.php"); class Ecua3 extends Opera{ public function calcula($a,$b,$c) { $this->resta($a,$b); $this->resta($this->rr,$c); echo "<br>el resultado de ecuacion 3 es ".$this->rr; } } ?> Ecua4.php <?php require_once("opera.php"); class Ecua4 extends Opera{ public function calcula($a,$c,$b){ $this->resta($a,$c); $this->resta($this->rr,$b); echo "<br>el resultado de ecuacion 4 es ".$this->rr; } } ?>

Ecua5.php <?php require_once("opera.php"); class Ecua5 extends Opera{ public function calcula($a,$b,$c){ $this->multiplica($a,$b); $this->multiplica($this->rm,$c); echo "<br>el resultado de ecuacion 5 es ".$this->rm; } } ?> Ecua6.php <?php require_once("opera.php"); class Ecua6 extends Opera{ public function calcula($a,$b,$c){ $this->dividir($a,$b); $this->dividir($this->rd,$c); echo "<br>el resultado de ecuacion 6 es ".$this->rd; } } ?>

<?php abstract class Opera{ protected $_rs; protected $_rm; protected $_rr; protected $_rd; public function suma($va,$vb) { $this->rs = $va+$vb; }

public function resta($va,$vb) { $this->rr = $va-$vb; }

public function multiplica($va,$vb) { $this->rm = $va*$vb; }

public function dividir($va,$vb) { $this->rd = $va/$vb; }

public function getRs() { return $this->rs; }

public function getRr() { return $this->rr; }

public function getRm() { return $this->rm; }

public function getRd() { return $this->rd; }

} ?>

<?php require_once("ecua1.php"); require_once("ecua2.php"); require_once("ecua3.php"); require_once("ecua4.php"); require_once("ecua5.php"); require_once("ecua6.php"); // ecuacion 1 es A + B + C $ecua1 = new Ecua1(); $ecua1->calcula($_POST['a'],$_POST['b'],$_POST['c']); // ecuacion 2 es A + B - C $ecua2 = new Ecua2(); $ecua2->calcula($_POST['a'],$_POST['b'],$_POST['c']); // ecuacion 3 es A - B - C $ecua3 = new Ecua3(); $ecua3->calcula($_POST['a'],$_POST['b'],$_POST['c']); // ecuacion 4 es A - C - B $ecua4 = new Ecua4(); $ecua4->calcula($_POST['a'],$_POST['c'],$_POST['b']); //ecuacion 5 es A * B * C $ecua5 = new Ecua5(); $ecua5->calcula($_POST['a'],$_POST['b'],$_POST['c']); //ecuacion 6 es A / B / C $ecua6 = new Ecua6(); $ecua6->calcula($_POST['a'],$_POST['b'],$_POST['c']);

?>