Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update task.md #28

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
- Implement a separate class for each payment method: `CreditCardPayment`, `PayPalPayment`, and `BitcoinPayment`.
Each of these classes should implement the base `PaymentStrategy` interface and override the `processPayment`
method.
- Create a `PaymentProcessor` class that encapsulates the payment behavior.
- Create a `PaymentProcessor` class that encapsulates payment behavior.
This class should take as a constructor parameter `PaymentStrategy paymentStrategy`
and should contain the `processOrderPayment` method, which invokes the `processPayment` method from `paymentStrategy`.
- Transform the `Order` class into a class that only stores the order's total amount and date data. Implement getters for these fields.
- Within the `Main::main` method, instantiate an `Order` object for each order and a `PaymentProcessor` for each payment type.
Make sure to pass the corresponding payment strategy when creating the `PaymentProcessor` object.

By using the **Strategy** design pattern, the payment processing logic is separated from the `Order` class,
By using the **Strategy** design pattern, payment processing logic is separated from the `Order` class,
making it more flexible and maintainable.
Adding new payment methods or modifying the existing ones is easier and doesn't affect the `Order` class.
Adding new payment methods or modifying existing ones becomes easier and doesn't affect the `Order` class.
The client code also becomes cleaner, as it focuses on creating instances of `PaymentProcessor` with the desired payment
strategies.

Expand All @@ -23,7 +23,7 @@ strategies.
<div class="hint" title="Where to start?">

The file where you should write the code is already open.
Please, create an interface named `PaymentStrategy` and add `void processPayment(Double amount)` method.
Please create an interface named `PaymentStrategy` and add the `void processPayment(Double amount)` method.
</div>

<div class="hint" title="How should PaymentProcessor class look?">
Expand Down
Loading