diff --git a/TypeScript/app/update-behaviors/implementations/aged-brie-behavior.spec.ts b/TypeScript/app/update-behaviors/implementations/aged-brie/aged-brie-behavior.spec.ts similarity index 100% rename from TypeScript/app/update-behaviors/implementations/aged-brie-behavior.spec.ts rename to TypeScript/app/update-behaviors/implementations/aged-brie/aged-brie-behavior.spec.ts diff --git a/TypeScript/app/update-behaviors/implementations/aged-brie-behavior.ts b/TypeScript/app/update-behaviors/implementations/aged-brie/aged-brie-behavior.ts similarity index 66% rename from TypeScript/app/update-behaviors/implementations/aged-brie-behavior.ts rename to TypeScript/app/update-behaviors/implementations/aged-brie/aged-brie-behavior.ts index a21e1a50..9e3ca51e 100644 --- a/TypeScript/app/update-behaviors/implementations/aged-brie-behavior.ts +++ b/TypeScript/app/update-behaviors/implementations/aged-brie/aged-brie-behavior.ts @@ -1,23 +1,22 @@ +import { config } from "@app/config"; import { Item } from "@app/item"; -import { IUpdateBehavior } from "../update-behavior.interface"; +import { IUpdateBehavior } from "@app/update-behaviors"; export class AgedBrieBehavior implements IUpdateBehavior { - readonly #MAX_AMOUNT = 50; - constructor(private item: Item) {} update(): Item { - this.item.sellIn -= 1; - - const isPastSellInDay = this.item.sellIn < 0; + const isPastSellInDay = this.item.sellIn <= 0; const amountToAdd = isPastSellInDay ? 2 : 1; this.item.quality = Math.min( - this.#MAX_AMOUNT, + config.maxQuality, this.item.quality + amountToAdd ); + this.item.sellIn -= 1; + return this.item; } }