mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
35 lines
860 B
Swift
35 lines
860 B
Swift
//
|
|
// File.swift
|
|
//
|
|
//
|
|
// Created by Manali Mogre on 16/08/2020.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
protocol CustomisedItem {
|
|
var item: Item {get set}
|
|
func updateItemState()
|
|
}
|
|
|
|
protocol CustomisedItemFactoryCreator {
|
|
static func getCustomisedItem(item: Item) -> CustomisedItem
|
|
}
|
|
|
|
|
|
struct CustomisedItemFactory: CustomisedItemFactoryCreator {
|
|
// Returns the Customised Item based on the Item name
|
|
static func getCustomisedItem(item: Item) -> CustomisedItem {
|
|
switch item.name {
|
|
case ItemNameConstants.kAgedBrieItem:
|
|
return AgedBrieItem(item: item)
|
|
case ItemNameConstants.kBackstagePassesItem:
|
|
return BackstagePassesItem(item: item)
|
|
case ItemNameConstants.kSulfurasItem:
|
|
return SulfurasItem(item: item)
|
|
default:
|
|
return StandardItem(item: item)
|
|
}
|
|
}
|
|
}
|