Add exams from exam156 to exam199
This commit is contained in:
49
exam197/index.php
Normal file
49
exam197/index.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class BankAccount
|
||||
{
|
||||
|
||||
public $balance = 0;
|
||||
public $type = '';
|
||||
|
||||
public function SetType($input){
|
||||
$this->type = $input;
|
||||
}
|
||||
|
||||
public function DisplayBalance()
|
||||
{
|
||||
return 'Balance: ' . $this->balance . '<br>';
|
||||
}
|
||||
|
||||
public function Withdraw($amount)
|
||||
{
|
||||
if ($this->balance < $amount) {
|
||||
echo 'Not enough money <br> ';
|
||||
} else {
|
||||
$this->balance = $this->balance - $amount;
|
||||
}
|
||||
}
|
||||
|
||||
public function Deposit($amount){
|
||||
$this->balance = $this->balance + $amount;
|
||||
}
|
||||
}
|
||||
|
||||
class SavingsAccount extends BankAccount {
|
||||
}
|
||||
|
||||
$alex = new BankAccount;
|
||||
$alex->SetType('18-25 Current');
|
||||
$alex->Deposit(100);
|
||||
$alex->Withdraw(20);
|
||||
|
||||
$alex_savings = new SavingsAccount;
|
||||
$alex_savings -> Deposit(40);
|
||||
$alex_savings->SetType('Super Saver');
|
||||
|
||||
|
||||
echo $alex-> type .' has ' .$alex->DisplayBalance();
|
||||
echo $alex_savings->type .' has ' .$alex_savings->DisplayBalance();
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user