Created
December 27, 2012 23:36
-
-
Save tadas-subonis/4393185 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
//regular customer | |
class Customer { | |
private String name; | |
String getName() { | |
return name; | |
} | |
boolean canCancelDispatchedOrder() { | |
return false; | |
} | |
} | |
//In case valid user isn't logged in | |
class GuestCustomer extends Customer{ | |
@Override | |
String getName() { | |
return "Anonymous"; | |
} | |
} | |
//Customer for special order cancelling to use by support team | |
class SuperUserCustomer extends Customer { | |
@Override | |
boolean canCancelDispatchedOrder() { | |
return true; | |
} | |
} | |
//hides our inheritance tree complexity and helps to construct appropriate | |
//object as needed | |
class CustomerFactory { | |
Customer getCustomer(Context context){ | |
//[...] | |
return customer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment