Created
July 24, 2021 18:38
-
-
Save alex-ber/52dd802de60290a4e7ca10a58ecfe098 to your computer and use it in GitHub Desktop.
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
| import java.util.Objects; | |
| public class Pizza implements Delivarable { | |
| public enum PizzaStatus { | |
| IN_PROGRESS, | |
| READY, | |
| DELIVERED; | |
| } | |
| private PizzaStatus pizzaStatus = PizzaStatus.IN_PROGRESS; | |
| private PizzaDeliveryStrategy strategy; | |
| public Pizza(PizzaDeliveryStrategy strategy){ | |
| this.strategy = Objects.requireNotNull(strategy); | |
| } | |
| public void getStatus(PizzaStatus pizzaStatus){ | |
| return this.pizzaStatus; | |
| } | |
| public void setStatus(PizzaStatus pizzaStatus){ | |
| this.pizzaStatus = pizzaStatus; | |
| } | |
| @Override | |
| public void deliver(){ | |
| if (isDeliverable()) { | |
| this.strategy.deliver(this); | |
| this.setStatus(PizzaStatus.DELIVERED); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment