Last active
August 29, 2015 13:58
-
-
Save netkiller/10347249 to your computer and use it in GitHub Desktop.
Withdrawal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Withdrawal{ | |
public $money = 0; | |
function __construct($money){ | |
$this->money = $money; | |
} | |
public function total(){ | |
return $this->money; | |
} | |
} | |
class Fee{ | |
function __construct($withdrawal, $item) { | |
$withdrawal->money = $withdrawal->money - $item->money; | |
} | |
} | |
class Bounty{ | |
function __construct($money){ | |
$this->money = $money; | |
} | |
} | |
class OldBounty{ | |
function __construct($money){ | |
$this->money = $money; | |
} | |
} | |
class Money { | |
function __construct($money){ | |
$this->money = $money; | |
} | |
function getMoney(){ | |
return $this->money; | |
} | |
} | |
class Exchange { | |
function __construct($money, $item) { | |
$money->money = $money->getMoney() * $item->rate; | |
} | |
} | |
class USD { | |
public $rate = 6.5; | |
function __construct(){ | |
} | |
} | |
class HKD { | |
private $rate = 1.5; | |
function __construct(){ | |
} | |
} | |
class RMB { | |
private $rate = 3.5; | |
function __construct(){ | |
} | |
} | |
$withdrawal = new Withdrawal(100); | |
$fee = new Fee($withdrawal, new Bounty(20)); | |
$fee = new Fee($withdrawal, new OldBounty(10)); | |
printf("%f \n",$withdrawal->total()); | |
$money = new Money($withdrawal->total()); | |
$exchange = new Exchange($money, new USD()); | |
printf("%f \n",$money->getMoney()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment