Skip to content

Instantly share code, notes, and snippets.

@marclundgren
Forked from blzaugg/restroomEtiquette.js
Last active December 15, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marclundgren/5209258 to your computer and use it in GitHub Desktop.
Save marclundgren/5209258 to your computer and use it in GitHub Desktop.
function restroomEtiquette(you, restroom) {
var toilet = restroom.toilet,
urinal = restroom.urinal;
while (true) {
if (you.needToGo === 1) {
if (you.urinalsOkay && restroom.urinalAvailable()) {
you.evacuate();
urinal.flush();
if (you.madeMess) {
you.cleanUp();
}
break;
}
else if (restroom.stallAvailable()) {
if (you.positionPref === 'stand') {
toilet.liftSeat(); // yes you
}
you.evacuate();
// if (toilet.yellowLetItMellow) {
// toilet.flush();
// }
toilet.flush();
if (you.madeMess) {
you.cleanUp();
}
break;
}
else {
you.dance();
continue; // you'll have to wait
}
}
else if (you.needToGo === 2) {
if (restroom.stallAvailable()) {
you.evacuate();
toilet.flush();
if (you.madeMess) {
you.cleanUp();
}
break;
}
else {
you.dance();
continue; // you'll have to wait
}
}
else if (you.needToGo === 3) {
if (restroom.stallAvailable()) {
you.evacuate();
toilet.flush();
if (you.madeMess) {
you.cleanUp();
}
else {
you.cleanUp(); // yes you did
}
break;
}
else {
you.dance();
continue; // you'll have to wait
}
}
else {
you.hurryHome();
break;
}
}
// if (me.handsSoiled) {
// me.washHands();
// }
me.washHands(); // you never know
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment