From 53b77f6a8c1d5d8ab2aa77d464852eb30d7b835f Mon Sep 17 00:00:00 2001 From: Velizar Todorov Date: Tue, 30 Nov 2021 19:03:34 +0100 Subject: [PATCH] :hammer: move `validateQuality()` to `GildedRose` class --- .../java/com/gildedrose/item_helpers/ItemFactory.java | 1 - src/main/java/com/gildedrose/main/GildedRose.java | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gildedrose/item_helpers/ItemFactory.java b/src/main/java/com/gildedrose/item_helpers/ItemFactory.java index efa54fbb..e5550367 100644 --- a/src/main/java/com/gildedrose/item_helpers/ItemFactory.java +++ b/src/main/java/com/gildedrose/item_helpers/ItemFactory.java @@ -22,7 +22,6 @@ public class ItemFactory { if (itemType == null) { itemType = new NormalItem(item); } - itemType.validateQuality(); return itemType; } diff --git a/src/main/java/com/gildedrose/main/GildedRose.java b/src/main/java/com/gildedrose/main/GildedRose.java index 553748e1..67a3f7a9 100644 --- a/src/main/java/com/gildedrose/main/GildedRose.java +++ b/src/main/java/com/gildedrose/main/GildedRose.java @@ -1,5 +1,7 @@ package com.gildedrose.main; +import com.gildedrose.item_helpers.ItemType; + import static com.gildedrose.item_helpers.ItemFactory.getItemType; import static java.util.Arrays.stream; @@ -11,6 +13,10 @@ public class GildedRose { } public void updateQuality() { - stream(items).forEach(item -> getItemType(item).updateQuality()); + stream(items).forEach(item -> { + ItemType itemType = getItemType(item); + itemType.validateQuality(); + itemType.updateQuality(); + }); } }