Created
February 9, 2026 16:49
-
-
Save pazteddy/bfb26b30a0e3da7d8d9b4493ac92ef48 to your computer and use it in GitHub Desktop.
Clases Customer, Room e interfaz de pago PaymentMethod
This file contains hidden or 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 | |
| declare(strict_types=1); | |
| class Customer | |
| { | |
| public function __construct( | |
| public string $name, | |
| public string $email | |
| ) {} | |
| } | |
| class Room | |
| { | |
| public function __construct( | |
| public string $name, | |
| private float $pricePerNight | |
| ) {} | |
| public function price(): float | |
| { | |
| return $this->pricePerNight; | |
| } | |
| } | |
| interface PaymentMethod | |
| { | |
| public function pay(float $amount): string; | |
| } | |
| class CardPayment implements PaymentMethod | |
| { | |
| public function pay(float $amount): string | |
| { | |
| return "Pago con tarjeta aprobado"; | |
| } | |
| } | |
| class QrPayment implements PaymentMethod | |
| { | |
| public function pay(float $amount): string | |
| { | |
| return "Pago con QR aprobado"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment