-
-
Save genkovich/de5625b5746c3aae0a6e93ac653d6924 to your computer and use it in GitHub Desktop.
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 Customer | |
{ | |
protected float $account = 0; | |
public function putMoneyIntoAccount(int|float $sum): void | |
{ | |
if ($sum < 1) { | |
throw new Exception('Вы не можете положить на счёт меньше 1$'); | |
} | |
$this->account += $sum; | |
} | |
} | |
class MicroCustomer extends Customer | |
{ | |
public function putMoneyIntoAccount(int|float $sum): void | |
{ | |
if ($sum < 1) { | |
throw new Exception('Вы не можете положить на счёт меньше 1$'); | |
} | |
// Усиление предусловий | |
if ($sum > 100) { | |
throw new Exception('Вы не можете положить на больше 100$'); | |
} | |
$this->account += $sum; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment