Skip to content

Instantly share code, notes, and snippets.

@sudomaxime
Created July 29, 2020 21:46
Show Gist options
  • Save sudomaxime/16dc7372765422e1fcd3fd6e9932cf00 to your computer and use it in GitHub Desktop.
Save sudomaxime/16dc7372765422e1fcd3fd6e9932cf00 to your computer and use it in GitHub Desktop.
import GoodBoyEvaluator from "./GoodBoyEvaluator";
class Dog {
private gotCookie: boolean;
public name: string;
constructor (name) {
this.name = name;
}
giveCookies (): void {
const boy = new GoodBoyEvaluator(this);
if (boy.worthyOfCookies) {
console.log(`${this.name}, got cookies !`)
this.gotCookies = true;
}
}
}
var dogs: Array<Dogs> = [
new Dog("Philibert"),
new Dog("Clifford")
];
dogs.forEach(dog => dog.giveCookies());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment