Skip to content

Instantly share code, notes, and snippets.

@alex-ber
Created July 30, 2021 19:48
Show Gist options
  • Select an option

  • Save alex-ber/2f36c639ff0947fcd5b906b7790e19e7 to your computer and use it in GitHub Desktop.

Select an option

Save alex-ber/2f36c639ff0947fcd5b906b7790e19e7 to your computer and use it in GitHub Desktop.
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