diff --git a/swift/Sources/GildedRose/GildedRose.swift b/swift/Sources/GildedRose/GildedRose.swift index 024d9870..2e1cf4d2 100644 --- a/swift/Sources/GildedRose/GildedRose.swift +++ b/swift/Sources/GildedRose/GildedRose.swift @@ -7,25 +7,25 @@ public class GildedRose { public func updateQuality() { for i in 0 ..< items.count { - if (items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert") { - if (items[i].quality > 0) { - if (items[i].name != "Sulfuras, Hand of Ragnaros") { + if items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert" { + if items[i].quality > 0 { + if items[i].name != "Sulfuras, Hand of Ragnaros" { items[i].quality = items[i].quality - 1 } } } else { - if (items[i].quality < 50) { + if items[i].quality < 50 { items[i].quality = items[i].quality + 1 - if (items[i].name == "Backstage passes to a TAFKAL80ETC concert") { - if (items[i].sellIn < 11) { - if (items[i].quality < 50) { + if items[i].name == "Backstage passes to a TAFKAL80ETC concert" { + if items[i].sellIn < 11 { + if items[i].quality < 50 { items[i].quality = items[i].quality + 1 } } - if (items[i].sellIn < 6) { - if (items[i].quality < 50) { + if items[i].sellIn < 6 { + if items[i].quality < 50 { items[i].quality = items[i].quality + 1 } } @@ -33,15 +33,15 @@ public class GildedRose { } } - if (items[i].name != "Sulfuras, Hand of Ragnaros") { + if items[i].name != "Sulfuras, Hand of Ragnaros" { items[i].sellIn = items[i].sellIn - 1 } - if (items[i].sellIn < 0) { - if (items[i].name != "Aged Brie") { - if (items[i].name != "Backstage passes to a TAFKAL80ETC concert") { - if (items[i].quality > 0) { - if (items[i].name != "Sulfuras, Hand of Ragnaros") { + if items[i].sellIn < 0 { + if items[i].name != "Aged Brie" { + if items[i].name != "Backstage passes to a TAFKAL80ETC concert" { + if items[i].quality > 0 { + if items[i].name != "Sulfuras, Hand of Ragnaros" { items[i].quality = items[i].quality - 1 } } @@ -49,7 +49,7 @@ public class GildedRose { items[i].quality = items[i].quality - items[i].quality } } else { - if (items[i].quality < 50) { + if items[i].quality < 50 { items[i].quality = items[i].quality + 1 } } diff --git a/swift/Sources/GildedRose/Item.swift b/swift/Sources/GildedRose/Item.swift index dbd81b12..d579d010 100644 --- a/swift/Sources/GildedRose/Item.swift +++ b/swift/Sources/GildedRose/Item.swift @@ -12,6 +12,6 @@ public class Item { extension Item: CustomStringConvertible { public var description: String { - return self.name + ", " + String(self.sellIn) + ", " + String(self.quality); + name + ", " + String(sellIn) + ", " + String(quality); } } diff --git a/swift/Sources/GildedRoseApp/main.swift b/swift/Sources/GildedRoseApp/main.swift index 8b39590f..78618ee4 100644 --- a/swift/Sources/GildedRoseApp/main.swift +++ b/swift/Sources/GildedRoseApp/main.swift @@ -15,7 +15,7 @@ let items = [ let app = GildedRose(items: items); var days = 2; -if (CommandLine.argc > 1) { +if CommandLine.argc > 1 { days = Int(CommandLine.arguments[1])! + 1 }