Created
July 30, 2021 19:48
-
-
Save alex-ber/2f36c639ff0947fcd5b906b7790e19e7 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 CocaCola implements Delivarable { | |
| private DelivarableStatus status = DelivarableStatus.IN_PROGRESS; | |
| private CocaColaDeliveryStrategy strategy; | |
| public CocaCola(CocaColaDeliveryStrategy strategy){ | |
| this.strategy = Objects.requireNotNull(strategy); | |
| } | |
| public void getStatus(DelivarableStatus status){ | |
| return this.status; | |
| } | |
| public void setStatus(DelivarableStatus status){ | |
| this.status = status; | |
| } | |
| @Override | |
| public void deliver(){ | |
| if (isDeliverable()) { | |
| this.strategy.deliver(this); | |
| this.setStatus(DelivarableStatus.DELIVERED); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment