mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
57 lines
1.2 KiB
Swift
57 lines
1.2 KiB
Swift
//
|
|
// File.swift
|
|
//
|
|
//
|
|
// Created by Manali Mogre on 16/08/2020.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
protocol CustomisedItemProtocol {
|
|
func updateCustomItemQuality()
|
|
}
|
|
|
|
|
|
protocol ItemSellInDaysProtocol {
|
|
func reduceSellInDaysByOne(item: Item)
|
|
}
|
|
|
|
extension ItemSellInDaysProtocol {
|
|
func reduceSellInDaysByOne(item: Item) {
|
|
item.sellIn -= 1
|
|
}
|
|
|
|
func HasSellInDatePassed(item: Item) -> Bool {
|
|
return item.sellIn < 0
|
|
}
|
|
}
|
|
|
|
protocol ItemQualityProtocol {
|
|
|
|
}
|
|
|
|
extension ItemQualityProtocol {
|
|
func isItemUnderHighestQuality(item: Item) -> Bool {
|
|
return item.quality < ValueConstants.kHightestQualityValue
|
|
}
|
|
func reduceQuality(for item: Item, by value:Int) {
|
|
item.quality -= value
|
|
}
|
|
|
|
func increaseQuality(for item: Item, by value:Int) {
|
|
item.quality += value
|
|
}
|
|
|
|
func isItemOverLowestQuality(item: Item) -> Bool {
|
|
return item.quality > ValueConstants.kLowestQualityValue
|
|
}
|
|
|
|
func setItemQualityToZero(item: Item) {
|
|
item.quality = ValueConstants.kLowestQualityValue
|
|
}
|
|
|
|
func setItemQualityToFifty(item: Item) {
|
|
item.quality = ValueConstants.kHightestQualityValue
|
|
}
|
|
}
|