Created
May 6, 2016 20:09
-
-
Save BobGu/e1b504ab6d2b423fd3cbfaf32485921d to your computer and use it in GitHub Desktop.
This file contains 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
public class Order { | |
State unpaidState; | |
State paidState; | |
State shippedState; | |
State deliveredState; | |
State state = unpaidState; | |
public Order() { | |
unpaidState = new UnpaidState(this); | |
paidState = new PaidState(this); | |
shippedState = new ShippedState(this); | |
deliveredState = new DeliveredState(this); | |
} | |
public State getUnpaidState() { | |
return unpaidState; | |
} | |
public State getPaidState() { | |
return paidState; | |
} | |
public State getShippedState() { | |
return shippedState; | |
} | |
public State getDeliveredState() { | |
return deliveredState; | |
} | |
public void verifyCreditCard(String info) { | |
state.verifyCreditCard(info); | |
} | |
public void ship() { | |
state.ship(); | |
} | |
public void orderDelivered() { | |
state.orderDelivered(); | |
} | |
public void setState(State state) { | |
this.state = state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment