Changing static function to class function to allow method overriding

This commit is contained in:
Manali Mogre 2020-08-18 21:32:37 +02:00
parent 576ecc136d
commit e9541d42b8
2 changed files with 4 additions and 3 deletions

View File

@ -11,9 +11,9 @@ protocol CustomisedItemFactoryCreator {
static func getCustomisedItem(item: Item) -> CustomisedItem static func getCustomisedItem(item: Item) -> CustomisedItem
} }
struct CustomisedItemFactory: CustomisedItemFactoryCreator { class CustomisedItemFactory: CustomisedItemFactoryCreator {
// Returns the Customised Item based on the Item name // Returns the Customised Item based on the Item name
static func getCustomisedItem(item: Item) -> CustomisedItem { class func getCustomisedItem(item: Item) -> CustomisedItem {
switch item.name { switch item.name {
case ItemNameConstants.kAgedBrieItem: case ItemNameConstants.kAgedBrieItem:
return AgedBrieItem(item: item) return AgedBrieItem(item: item)
@ -26,3 +26,4 @@ struct CustomisedItemFactory: CustomisedItemFactoryCreator {
} }
} }
} }

View File

@ -7,7 +7,7 @@
import Foundation import Foundation
struct StandardItem: CustomisedItem, ItemStateUpdater { class StandardItem: CustomisedItem, ItemStateUpdater {
var item: Item var item: Item
private var isSellInDatePassed: Bool{ private var isSellInDatePassed: Bool{