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