Advertisement
Gleidson_21

abstracao

Jul 30th, 2021
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class Banco {
  4.     protected $saldo;
  5.     protected $limiteSaque;
  6.     protected $juros;
  7.  
  8.     public function setSaldo($s){
  9.         $this->saldo = $s;
  10.     }
  11.  
  12.     public function getSaldo(){
  13.         return $this->saldo;
  14.     }
  15.  
  16.     abstract protected function Sacar($s);
  17.  
  18.     abstract protected function Depositar($d);
  19.  
  20.  
  21.    
  22. }
  23.  
  24. class Itau extends Banco {
  25.     public function Sacar($s){
  26.         $this->saldo -= $s;
  27.         echo "<hr> Sacou: ".$s;
  28.     }
  29.  
  30.     public function Depositar($d){
  31.         $this->saldo += $d;
  32.         echo "<hr> Depositou: ".$d;
  33.     }
  34. }
  35.  
  36. $itau = new Itau();
  37. $itau->setSaldo(1000);
  38. echo "<hr> saldo: ".$itau->getSaldo();
  39. $itau->Sacar(250);
  40. echo "<hr> saldo: ".$itau->getSaldo();
  41.  
  42. $itau->Depositar(900);
  43. echo "<hr> saldo: ".$itau->getSaldo();
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement