Skip to content

Instantly share code, notes, and snippets.

@blzaugg
Created March 20, 2013 22:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save blzaugg/5209040 to your computer and use it in GitHub Desktop.
Save blzaugg/5209040 to your computer and use it in GitHub Desktop.
restroomEtiquette
function restroomEtiquette(you, restroom) {
while (true) {
if (you.needToGo === 1) {
if (you.okayWithUrinals && restroom.urinalAvailable()) {
var urinal = restroom.occupyAvailableUrinal(you);
you.evacuate(urinal);
urinal.flush();
if (you.madeMess(urinal)) {
you.cleanUp(urinal);
}
break;
}
else if (restroom.toiletAvailable()) {
var toilet = restroom.occupyAvailableToilet(you);
if (you.positionPref(toilet) === 'stand') {
toilet.liftSeat(); // yes you
}
you.evacuate(toilet);
// if (!toilet.letItMellow('yellow')) {
// toilet.flush();
// }
toilet.flush();
if (you.madeMess(toilet)) {
you.cleanUp(toilet);
}
break;
}
else {
you.wait();
continue;
}
}
else if (you.needToGo === 2) {
if (restroom.toiletAvailable()) {
var toilet = restroom.occupyAvailableToilet(you);
you.evacuate(toilet);
toilet.flush();
if (you.madeMess(toilet)) {
you.cleanUp(toilet);
}
break;
}
else {
you.wait();
continue;
}
}
else if (you.needToGo === 3) {
if (restroom.toiletAvailable()) {
var toilet = restroom.occupyAvailableToilet(you);
you.evacuate(toilet);
toilet.flush();
if (you.madeMess(toilet)) {
you.cleanUp(toilet);
}
else {
you.cleanUp(toilet); // yes you did
}
break;
}
else {
you.wait();
continue;
}
}
else {
you.hurryHome();
break;
}
}
// if (you.handsSoiled) {
// you.washHands();
// }
you.washHands(); // you never know
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment