Skip to content

Instantly share code, notes, and snippets.

@reergymerej
Last active January 7, 2016 04:10
Show Gist options
  • Save reergymerej/5fbf04a5ba212181c36b to your computer and use it in GitHub Desktop.
Save reergymerej/5fbf04a5ba212181c36b to your computer and use it in GitHub Desktop.
function Andy() {
while (1) {
var animal = catchAnAnimal();
switch (animal.type) {
case 'meerkat':
Bob(animal);
break;
case 'ostrich':
Carol(animal);
break;
case 'snake':
Donald(animal);
break;
}
}
}
function Bob(animal) {
if (!animal.isTagged) {
addEarTag(animal);
}
if (!animal.hasHat) {
addHat(animal);
}
}
function Carol(animal) {
if (animal.type !== 'snake' && !animal.isTagged) {
addInnerEarTag(animal);
}
if (!animal.hasHat) {
addHat(animal);
}
}
function Donald(animal) {
if (!animal.hasLogo) {
sprayPaintLogo(animal);
}
Carol(animal);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment