Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/11/2011, 22:31
opzina2
 
Fecha de Ingreso: abril-2009
Mensajes: 46
Antigüedad: 15 años
Puntos: 1
Comenzando con POO.

Estoy empezando con POO y me gustaría que vean esta simple clase.

Código PHP:
Ver original
  1. class math {
  2.    
  3.     private $x;
  4.     private $y;
  5.     private $iva;
  6.    
  7.     public function __construct($iva) {
  8.         $this->iva = $iva;
  9.     }
  10.    
  11.     public function suma($valor1, $valor2) {
  12.         $this->x = $valor1;
  13.         $this->y = $valor2;
  14.        
  15.         $sumar = $this->x + $this->y;
  16.        
  17.         return $sumar;
  18.     }
  19.    
  20.     public function resta($valor1, $valor2) {
  21.         $this->x = $valor1;
  22.         $this->y = $valor2;
  23.        
  24.         $restar = $this->x - $this->y;
  25.        
  26.         return $restar;
  27.     }
  28.    
  29.     public function division($valor1, $valor2) {
  30.         $this->x = $valor1;
  31.         $this->y = $valor2;
  32.        
  33.         $dividir = $this->x / $this->y;
  34.        
  35.         return $dividir;
  36.     }
  37.    
  38.     public function calculariva($valor) {
  39.         $iva = ($valor * $this->iva) / 100;
  40.        
  41.         return $iva;
  42.     }
  43.    
  44. }