- Code Refactoring : Adding function declarations in protocol

This commit is contained in:
Manali Mogre 2020-08-17 22:49:38 +02:00
parent 08c1415e17
commit 5e32a34b84
4 changed files with 7 additions and 4 deletions

View File

@ -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 {

View File

@ -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 }

View File

@ -7,7 +7,7 @@
import Foundation
struct BackstagePassesItem: ItemStateUpdater {
struct BackstagePassesItem: CustomisedItem, ItemStateUpdater {
var item: Item
private var isItemUnderHighestQuality: Bool {

View File

@ -7,7 +7,7 @@
import Foundation
struct StandardItem: ItemStateUpdater {
struct StandardItem: CustomisedItem, ItemStateUpdater {
var item: Item
private var isSellInDatePassed: Bool{