mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
30 lines
678 B
Swift
30 lines
678 B
Swift
//
|
|
// File.swift
|
|
//
|
|
//
|
|
// Created by Manali Mogre on 16/08/2020.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
struct AgedBrieItem: CustomisedItem, ItemStateUpdater{
|
|
var item: Item
|
|
|
|
private var isItemUnderHighestQuality: Bool {
|
|
return item.quality < ValueConstants.kHightestQualityValue
|
|
}
|
|
|
|
public init(item: Item) {
|
|
self.item = item
|
|
}
|
|
|
|
func updateItemState() {
|
|
// update the sell in days. Reduce the Sell In days by 1
|
|
self.reduceSellInDays(by: 1)
|
|
|
|
// Increment the Item quality by 1 if the quality is less than 50
|
|
guard isItemUnderHighestQuality else { return }
|
|
increaseItemQuality(by: 1)
|
|
}
|
|
}
|