Merge pull request #283 from jonreid/master

Make Swift more idiomatic
This commit is contained in:
Emily Bache 2021-12-08 15:57:21 +01:00 committed by GitHub
commit 1e98a364dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 18 deletions

View File

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

View File

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

View File

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