mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
- Code Refactoring : Adding function declarations in protocol
This commit is contained in:
parent
08c1415e17
commit
5e32a34b84
@ -8,6 +8,9 @@
|
||||
import Foundation
|
||||
|
||||
protocol ItemQualityUpdater: CustomisedItem {
|
||||
func reduceItemQuality(by value:Int)
|
||||
func increaseItemQuality(by value:Int)
|
||||
func setItemQuality(to value: Int)
|
||||
}
|
||||
|
||||
extension ItemQualityUpdater {
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct AgedBrieItem: ItemStateUpdater{
|
||||
struct AgedBrieItem: CustomisedItem, ItemStateUpdater{
|
||||
var item: Item
|
||||
|
||||
private var isItemUnderHighestQuality: Bool {
|
||||
@ -20,7 +20,7 @@ struct AgedBrieItem: ItemStateUpdater{
|
||||
|
||||
func updateItemState() {
|
||||
// update the sell in days. Reduce the Sell In days by 1
|
||||
reduceSellInDays(by: 1)
|
||||
self.reduceSellInDays(by: 1)
|
||||
|
||||
// Increment the Item quality by 1 if the quality is less than 50
|
||||
guard isItemUnderHighestQuality else { return }
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct BackstagePassesItem: ItemStateUpdater {
|
||||
struct BackstagePassesItem: CustomisedItem, ItemStateUpdater {
|
||||
var item: Item
|
||||
|
||||
private var isItemUnderHighestQuality: Bool {
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct StandardItem: ItemStateUpdater {
|
||||
struct StandardItem: CustomisedItem, ItemStateUpdater {
|
||||
var item: Item
|
||||
|
||||
private var isSellInDatePassed: Bool{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user