Created
November 26, 2018 14:04
-
-
Save ragmha/0b2afdd498b3ea909ff2e43d9eedc8ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pizza { | |
constructor(private name: string, private price: number) {} | |
} | |
class List<T> { | |
private list: T[] = []; | |
addItem(item: T): void { | |
this.list.push(item); | |
} | |
getList(): T[] { | |
return this.list; | |
} | |
} | |
const list = new List<Pizza>(); | |
list.addItem(new Pizza("Pepperoni", 15)); | |
const pizzas = list.getList(); | |
class Coupon { | |
constructor(private name: string) {} | |
} | |
const anotherList = new List<Coupon>(); | |
anotherList.addItem(new Coupon("PIZZA25")); | |
const cupons = anotherList.getList(); | |
console.log(pizzas); | |
console.log(cupons); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment