From 15adb25bd2c9b909e8ffb87bf5c93d35f5e7d7d4 Mon Sep 17 00:00:00 2001 From: Userbit <34487074+Userbit@users.noreply.github.com> Date: Thu, 13 Feb 2020 15:34:13 +0300 Subject: [PATCH] Change `Number` type to `number` --- decorator/decorator.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/decorator/decorator.ts b/decorator/decorator.ts index a0d3783..544bc96 100644 --- a/decorator/decorator.ts +++ b/decorator/decorator.ts @@ -1,9 +1,9 @@ interface Coffee { - cost(): Number; + cost(): number; } class GeneralCoffee implements Coffee { - cost(): Number { + cost(): number { return 10; } } @@ -15,25 +15,25 @@ class CoffeeExtraDecorator implements Coffee { this._coffee = coffee; } - cost(): Number { + cost(): number { return this._coffee.cost(); } } class BubbleDecorator extends CoffeeExtraDecorator { - private _price: Number = 3; + private _price: number = 3; - cost(): Number { - return super.cost().valueOf() + this._price.valueOf(); + cost(): number { + return super.cost() + this._price; } } class MilkDecorator extends CoffeeExtraDecorator { - private _price: Number = 2.5; - private _freshExtra: Number = 1.5; + private _price: number = 2.5; + private _freshExtra: number = 1.5; - cost(): Number { - return super.cost().valueOf() + this._price.valueOf() + this._freshExtra.valueOf(); + cost(): number { + return super.cost() + this._price + this._freshExtra; } } @@ -42,4 +42,4 @@ class MilkDecorator extends CoffeeExtraDecorator { const withBubble = new BubbleDecorator(general); const withMilk = new MilkDecorator(withBubble); console.log(`Total: ${withMilk.cost()}`); -})(); \ No newline at end of file +})();