Skip to content

Instantly share code, notes, and snippets.

@ckiee
Last active January 8, 2018 13:58
Show Gist options
  • Save ckiee/1141afa790c13b2134dd2dbd69272475 to your computer and use it in GitHub Desktop.
Save ckiee/1141afa790c13b2134dd2dbd69272475 to your computer and use it in GitHub Desktop.
My *first* TypeScript app, woo!
// This app is not intended to hurt any business, brand and/or person. This was made for educational purposes only.
enum BoopType {
BeepyBoop,
DankBoop,
DarkSoulBoop
}
class Boop {
name: string;
type: BoopType;
}
namespace LivingThings {
export enum Gender {
Male,
Female
}
export class HumanName {
constructor(first: string, last: string) {
this.first = first;
this.last = last;
}
first: string;
last: string;
getFull(): string {
return `${this.first} ${this.last}`;
}
}
export class Human {
constructor(name: HumanName, gender: Gender) {
this.name = name;
this.gender = gender;
}
name: HumanName; //humans usually have names
gender: Gender;
generateMessage(message: string): string {
return `${this.name.getFull()}: ${message}`;
}
}
export enum MemeHumanType {
MansNotHot,
PinkGuy
}
export class MemeHuman extends Human {
memeHumanType: MemeHumanType
constructor(name: HumanName, gender: Gender, memeHumanType: MemeHumanType) {
super(name, gender);
this.memeHumanType = memeHumanType;
}
generateMessage(message: string): string {
let prefix: string = `${this.name.getFull()} (${MemeHumanType[this.memeHumanType]}): `;
return prefix + message;
}
}
}
let mans: LivingThings.Human[] = [];
let hu = new LivingThings.Human(new LivingThings.HumanName("Ron", "Joopeppbpbppbbp"), LivingThings.Gender.Male);
mans.push(hu);
let danky = new LivingThings.MemeHuman(new LivingThings.HumanName("h3h3", "productions"),LivingThings.Gender.Male, LivingThings.MemeHumanType.MansNotHot);
mans.push(danky);
mans.forEach(man => console.log(man.generateMessage(`${man.name.first} not Hot`)));
@ckiee
Copy link
Author

ckiee commented Jan 8, 2018

also the data that is there is very inaccurate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment