Skip to content

Commit

Permalink
Fixed the example for Chain of Responsibility (kamranahmedse#49)
Browse files Browse the repository at this point in the history
Now it will actual give the same result as the example snippet before it was just returning:
Paid 259 using Bank
  • Loading branch information
Kinsmir authored and kamranahmedse committed Feb 21, 2017
1 parent ca5d8d9 commit 82af66e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ abstract class Account {

public function pay(float $amountToPay) {
if ($this->canPay($amountToPay)) {
echo sprintf('Paid %s using %s' . PHP_EOL, $amount, get_called_class());
echo sprintf('Paid %s using %s' . PHP_EOL, $amountToPay, get_called_class());
} else if ($this->successor) {
echo sprintf('Cannot pay using %s. Proceeding ..' . PHP_EOL, get_called_class());
$this->successor->pay($amountToPay);
Expand All @@ -1166,31 +1166,31 @@ abstract class Account {
}

public function canPay($amount) : bool {
return $this->balance <= $amount;
return $this->balance >= $amount;
}
}

class Bank extends Account {
protected $balance;

public function __construct(float $balance) {
$this->$balance = $balance;
$this->balance = $balance;
}
}

class Paypal extends Account {
protected $balance;

public function __construct(float $balance) {
$this->$balance = $balance;
$this->balance = $balance;
}
}

class Bitcoin extends Account {
protected $balance;

public function __construct(float $balance) {
$this->$balance = $balance;
$this->balance = $balance;
}
}
```
Expand Down

0 comments on commit 82af66e

Please sign in to comment.