Advertisement
hercioneto

PW2017 calc.class

Mar 27th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.     //arquivo calc.class.php
  3.    
  4.     class Calc {
  5.         private $numero1;
  6.         private $numero2;
  7.        
  8.         public function __construct() {
  9.             $this->numero1 = 0;
  10.             $this->numero2 = 0;
  11.         }
  12.        
  13.         public function getNumero1(){
  14.             return $this->numero1;
  15.         }
  16.        
  17.         public function setNumero1($numero1){
  18.             $this->numero1 = $numero1;
  19.         }
  20.        
  21.         public function getNumero2(){
  22.             return $this->numero2;
  23.         }
  24.        
  25.         public function setNumero2($numero2){
  26.             $this->numero2 = $numero2;
  27.         }
  28.        
  29.         public function somar() {
  30.             $soma = $this->numero1  + $this->numero2;
  31.             return $soma;
  32.         }
  33.        
  34.         public function diminuir() {
  35.             $valor = $this->numero1  - $this->numero2;
  36.             return $valor;
  37.         }
  38.        
  39.         public function multiplicar() {
  40.             $valor = $this->numero1  * $this->numero2;
  41.             return $valor;
  42.         }
  43.         public function dividir() {
  44.             if ($this->numero2==0) {
  45.                 return "ERRO";
  46.                 } else {
  47.                 $valor = $this->numero1  / $this->numero2;
  48.                 return $valor;
  49.             }
  50.         }
  51.        
  52.     }
  53.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement