Add exams from exam156 to exam199
This commit is contained in:
31
exam190/index.php
Normal file
31
exam190/index.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class BankAccount
|
||||
{
|
||||
// modifikatori vidljivosti u PHP public, protected, private
|
||||
public $balance = 42;
|
||||
|
||||
public function DisplayBalance()
|
||||
{
|
||||
return 'Balance: ' . $this->balance . '<br>'; // Ovako pristupamo vrednosti balance 'pravimo referencu'
|
||||
}
|
||||
|
||||
public function Withdraw($amount)
|
||||
{
|
||||
if ($this->balance < $amount) {
|
||||
echo 'Not enough money <br> ';
|
||||
} else {
|
||||
$this->balance = $this->balance - $amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//nova instanca klase
|
||||
$ba = new BankAccount;
|
||||
|
||||
|
||||
echo $ba->DisplayBalance();
|
||||
|
||||
$ba->Withdraw(50);
|
||||
|
||||
echo $ba->DisplayBalance();
|
||||
Reference in New Issue
Block a user