Skip to content

Instantly share code, notes, and snippets.

@dimitris-papadimitriou-chr
Created November 8, 2020 19:50
Show Gist options
  • Save dimitris-papadimitriou-chr/37159a1f07fc42718622ab92cdb6f0e8 to your computer and use it in GitHub Desktop.
Save dimitris-papadimitriou-chr/37159a1f07fc42718622ab92cdb6f0e8 to your computer and use it in GitHub Desktop.
export interface Product { getPrice(): number; }
export class ProductA implements Product {
private _price: number;
constructor(price: number) {
this._price = price;
}
getPrice(): number {
return this._price;
}
}
export class Packaging implements Product {
private _product: Product;
constructor(product: Product) {
this._product = product;
}
getPrice(): number {
return this._product.getPrice() + 0.5;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment