From e9541d42b842c67697a65b97f7f05819601564cf Mon Sep 17 00:00:00 2001 From: Manali Mogre Date: Tue, 18 Aug 2020 21:32:37 +0200 Subject: [PATCH] Changing static function to class function to allow method overriding --- swift/Sources/GildedRose/CustomisedItemFactory.swift | 5 +++-- swift/Sources/GildedRose/Items/StandardItem.swift | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/swift/Sources/GildedRose/CustomisedItemFactory.swift b/swift/Sources/GildedRose/CustomisedItemFactory.swift index a2194f58..539e0e15 100644 --- a/swift/Sources/GildedRose/CustomisedItemFactory.swift +++ b/swift/Sources/GildedRose/CustomisedItemFactory.swift @@ -11,9 +11,9 @@ protocol CustomisedItemFactoryCreator { static func getCustomisedItem(item: Item) -> CustomisedItem } -struct CustomisedItemFactory: CustomisedItemFactoryCreator { +class CustomisedItemFactory: CustomisedItemFactoryCreator { // Returns the Customised Item based on the Item name - static func getCustomisedItem(item: Item) -> CustomisedItem { + class func getCustomisedItem(item: Item) -> CustomisedItem { switch item.name { case ItemNameConstants.kAgedBrieItem: return AgedBrieItem(item: item) @@ -26,3 +26,4 @@ struct CustomisedItemFactory: CustomisedItemFactoryCreator { } } } + diff --git a/swift/Sources/GildedRose/Items/StandardItem.swift b/swift/Sources/GildedRose/Items/StandardItem.swift index 93ecb58f..f0b1e370 100644 --- a/swift/Sources/GildedRose/Items/StandardItem.swift +++ b/swift/Sources/GildedRose/Items/StandardItem.swift @@ -7,7 +7,7 @@ import Foundation -struct StandardItem: CustomisedItem, ItemStateUpdater { +class StandardItem: CustomisedItem, ItemStateUpdater { var item: Item private var isSellInDatePassed: Bool{