Skip to content

Instantly share code, notes, and snippets.

@nemecec
Last active December 27, 2015 03:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemecec/7261805 to your computer and use it in GitHub Desktop.
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