Skip to content

Instantly share code, notes, and snippets.

@tadas-subonis
Created December 27, 2012 23:36
Show Gist options
  • Save tadas-subonis/4393185 to your computer and use it in GitHub Desktop.
Save tadas-subonis/4393185 to your computer and use it in GitHub Desktop.
//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