Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
Last active August 1, 2021 17:28
Show Gist options
  • Save sebastiancarlos/99cd5cfc8bd6f51cd78bde068e2511c2 to your computer and use it in GitHub Desktop.
Save sebastiancarlos/99cd5cfc8bd6f51cd78bde068e2511c2 to your computer and use it in GitHub Desktop.
Kanye and the ontology of bleached T-shirts. A JavaScript implementation.
// Let's start by defining the ontology of our universe.
const BLEACH_TRANSFERENCE_RATIO = 0.5
class TShirt {
constructor() {
// By default, a T-shirt is clean.
this.stains = []
}
addStain(stain) {
this.stains.push(stain)
}
}
class Person {
constructor(name, occuppation, clothing) {
this.name = name
this.occuppation = occuppation
this.clothing = clothing
this.isFucking = null
this.isBeingFuckedBy = null
}
get tShirt() {
return this.clothing.find((piece) => piece instanceof TShirt)
}
fuck(person) {
// Throw error in case of self-fucking attempt.
if (person === this) {
throw 'Self-fucking is not available.'
}
// Update fucking status of the fucker and the fuckee.
this.isFucking = person
person.isBeingFuckedBy = this
// Perform transference of asshole content based on business logic.
const isFuckingModel = person instanceof Model
const isWearingTShirt = Boolean(this.tShirt)
const sheJustBleachedHerAsshole = person.assholeContent.includes('bleach')
if (isFuckingModel && isWearingTShirt && sheJustBleachedHerAsshole) {
// Note: You don't get bleach on your T-Shirt every time you fuck the model.
// Observe that the line is "And I get bleach on my T-shirt" instead of
// "Then I get bleach on my T-shirt". Suggesting that the outcome is not predictable.
if (Math.random() >= BLEACH_TRANSFERENCE_RATIO) {
this.tShirt.addStain('bleach')
}
}
}
}
class Rapper extends Person {
constructor(name, clothing) {
super(name, 'rapper', clothing)
}
get feeling() {
if (this.tShirt.stains.includes('bleach')) {
return 'like an asshole'
} else {
return 'ok'
}
}
}
class Model extends Person {
constructor() {
// By default, models are unnamed and naked (according to Kanye).
super(null, 'model', [])
this.assholeContent = []
}
bleachAsshole() {
if (!this.assholeContent.includes('bleach')) {
this.assholeContent.push('bleach')
}
}
}
// Showtime!
const kanye = new Rapper('Kanye', [new TShirt()])
const model = new Model()
model.bleachAsshole()
console.log(kanye.feeling) // 'ok'
kanye.fuck(model)
console.log(kanye.feeling) // 'like an asshole'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment