Skip to content

Instantly share code, notes, and snippets.

@nemecec
Last active December 27, 2015 03:48
Show Gist options
  • Select an option

  • Save nemecec/7261805 to your computer and use it in GitHub Desktop.

Select an option

Save nemecec/7261805 to your computer and use it in GitHub Desktop.
public enum AnimalType {
DOG {
public Animal createAnimal() {
return new Dog();
}
},
CAT {
public Animal createAnimal() {
return new Cat();
}
},
COW {
public Animal createAnimal() {
return new Cow();
}
},
ANY {
public Animal createAnimal() {
return new Cat();
}
};
public abstract Animal createAnimal();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment