You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
630 B
34 lines
630 B
<?php
|
|
class BankAccount
|
|
{
|
|
protected $balance = 0;
|
|
|
|
public function getBalance()
|
|
{
|
|
return $this->balance;
|
|
}
|
|
|
|
protected function setBalance($balance)
|
|
{
|
|
if ($balance >= 0) {
|
|
$this->balance = $balance;
|
|
} else {
|
|
throw new RuntimeException;
|
|
}
|
|
}
|
|
|
|
public function depositMoney($balance)
|
|
{
|
|
$this->setBalance($this->getBalance() + $balance);
|
|
|
|
return $this->getBalance();
|
|
}
|
|
|
|
public function withdrawMoney($balance)
|
|
{
|
|
$this->setBalance($this->getBalance() - $balance);
|
|
|
|
return $this->getBalance();
|
|
}
|
|
}
|