Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. class saskaita{
  3.     public $balance;
  4.     public static $incomeLimit = 500;
  5.     public static $outcomeLimit = 800;
  6.    
  7.     public function saskaita($balance){
  8.         $this->balance = $balance;
  9.     }
  10.     public function getBalance(){
  11.         return $this->balance;
  12.     }
  13.  
  14.     public function addToBalance($income){
  15.         if($this->incomeLimit < $income){
  16.             $this->balance += $income;
  17.         }
  18.     }
  19.     public function removeFromBalance($outcome){
  20.         if($this->outcomeLimit > $outcome && $outcome < $this->balance){
  21.             $this->balance -= $outcome;
  22.         }
  23.     }
  24. }
  25.  
  26. $sask = new saskaita(5000);
  27. $sask->addToBalance(400);
  28. echo $sask->getBalance();
  29. $sask->removeFromBalance(100);
  30. echo $sask->getBalance();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement