From f6a3a6d7186e6ecd7eb19bceb9085dfc0c735cc9 Mon Sep 17 00:00:00 2001 From: Chamoda Ranasinghe Date: Tue, 16 Jan 2024 02:30:10 +0700 Subject: [PATCH] added MAX_ITEM_QUALITY in constants file and referred it --- TypeScript/app/constants.ts | 5 +++-- TypeScript/app/gilded-rose.ts | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TypeScript/app/constants.ts b/TypeScript/app/constants.ts index a14863a0..4c3fbcac 100644 --- a/TypeScript/app/constants.ts +++ b/TypeScript/app/constants.ts @@ -1,4 +1,3 @@ - /* A const to hold the names of the items */ @@ -8,4 +7,6 @@ const ItemNames = { SULFURAS: "Sulfuras, Hand of Ragnaros", }; -export { ItemNames }; +const MAX_ITEM_QUALITY = 50; + +export { ItemNames, MAX_ITEM_QUALITY }; diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index dcfb43ef..d8c18125 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -1,5 +1,4 @@ -import { ItemNames } from "./constants"; - +import { ItemNames, MAX_ITEM_QUALITY } from "./constants"; export class Item { name: string; @@ -32,16 +31,16 @@ export class GildedRose { } } } else { - if (item.quality < 50) { + if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1; if (item.name == ItemNames.BACKSTAGE_PASSES) { if (item.sellIn < 11) { - if (item.quality < 50) { + if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1; } } if (item.sellIn < 6) { - if (item.quality < 50) { + if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1; } } @@ -63,7 +62,7 @@ export class GildedRose { item.quality = item.quality - item.quality; } } else { - if (item.quality < 50) { + if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1; } }