From cbaaa719fd3425777ec4cbb27d610191038395c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Maszczy=C5=84ski?= Date: Thu, 9 Jun 2022 20:17:36 +0200 Subject: [PATCH 1/2] add polish translation of requirements --- GildedRoseRequirements_pl.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 GildedRoseRequirements_pl.md diff --git a/GildedRoseRequirements_pl.md b/GildedRoseRequirements_pl.md new file mode 100644 index 00000000..63d940ab --- /dev/null +++ b/GildedRoseRequirements_pl.md @@ -0,0 +1,22 @@ +# Specyfikacja wymagań Pozłacanej Róży (Gilded Rose) + + +Cześć i witaj na pokładzie zespołu Pozłacanej Róży. Jak zapewne już wiesz, jesteśmy niewielką karczmą, która znajduje się w głównej części wspaniałego miasta i jest prowadzona przez przyjazną oberżystkę o imieniu Allison. Sprzedajemy i kupujemy tylko najlepsze towary. Niestety, przedmioty te tracą na jakości w miarę jak zbliża się ich termin sprzedaży. Korzystamy z systemu, który automatycznie aktualizuje stan naszego inwentarza. System ten został napisany przez rozsądnego typka o imieniu Leeroy, który postanowił poszukać nowych przygód. Twoim zadaniem jest dodanie nowej funkcjonalności do naszego systemu tak, abyśmy mogli rozpocząć sprzedaż nowego rodzaju przedmiotów. Pozwól, że najpierw zrobię ogólne wprowadzenie do systemu: +- Wszystkie przedmioty (`Item`) posiadają właściwość `SellIn`, która oznacza **liczbę dni pozostałych do upłynięcia terminu sprzedaży** przedmiotu +- Wszystkie przedmioty posiadają właściwość `Quality` (**jakość**), która wpływa na wartość przedmiotu +- Na koniec każdego dnia nasz system obniża wartość obu właściwości dla każdego przedmiotu + +Dość proste, prawda? No cóż, teraz zrobi się bardziej interesująco: +- Po upływie daty sprzedaży, jakość spada dwukrotnie szybciej +- Jakość przedmiotu nigdy nie jest ujemna +- Jakość "Starego Brie" (`Aged Brie`) rośnie wraz z wiekiem +- Jakość przedmiotu nigdy nie przekracza 50 +- Przedmiot legendarny `Sulfuras` nigdy nie musi być sprzedany, ani nie traci na jakości +- "Przepustka za kulisy" (`Backstage passes`), podobnie jak "Stary Brie", zyskują na jakości w miarę zbliżania się terminu sprzedaży; jakość wzrasta o 2, gdy jest 10 dni lub mniej i o 3, gdy jest 5 dni lub mniej, ale spada do 0 po koncercie (gdy `SellIn` < 0) + +Niedawno podpisaliśmy z dostawcą kontrakt na wyczarowane przedmioty. Wymaga to wprowadzenia zmiany do naszego systemu: +- "Wyczarowane" (`Conjured`) przedmioty tracą na jakości dwa razy szybciej niż normalne przedmioty + +Możesz wprowadzać dowolne zmiany w metodzie `UpdateQuality`, a także dodawać nowy kod, o ile wszystko nadal działa prawidłowo. Jednak nie zmieniaj klasy `Item` ani właściwości `Items`, które zostały napisane przez goblina w rogu, gdyż zaatakuje Cię on i zabije jednym strzałem, ponieważ nie wierzy we współdzielony kod (możesz zmienić metodę `UpdateQuality` oraz właściwość `Items` na statyczne, jeśli chcesz - będziemy Cię kryć!). + +Dla jasności: jakość przedmiotu nie może przekroczyć 50, jednak dla przedmiotu legendarnego `Sulfuras` jakość jest stale na poziomie 80 i nigdy nie spada. From 31afd92d955c5ff5ade6d20f4f726de128ffd4d1 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Fri, 10 Jun 2022 11:30:11 -0700 Subject: [PATCH 2/2] a - Apply SwiftFormat --- swift/Package.swift | 12 ++++++++---- swift/Sources/GildedRose/GildedRose.swift | 14 +++++++------- swift/Sources/GildedRose/Item.swift | 4 ++-- swift/Sources/GildedRoseApp/main.swift | 19 ++++++++++--------- .../GildedRoseTests/GildedRoseTests.swift | 1 - 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/swift/Package.swift b/swift/Package.swift index 79c4c79f..f52c7bb1 100644 --- a/swift/Package.swift +++ b/swift/Package.swift @@ -7,17 +7,21 @@ let package = Package( products: [ .library( name: "GildedRose", - targets: ["GildedRose"]), + targets: ["GildedRose"] + ), ], targets: [ .target( name: "GildedRose", - dependencies: []), + dependencies: [] + ), .target( name: "GildedRoseApp", - dependencies: ["GildedRose"]), + dependencies: ["GildedRose"] + ), .testTarget( name: "GildedRoseTests", - dependencies: ["GildedRose"]), + dependencies: ["GildedRose"] + ), ] ) diff --git a/swift/Sources/GildedRose/GildedRose.swift b/swift/Sources/GildedRose/GildedRose.swift index 2e1cf4d2..ea0aa861 100644 --- a/swift/Sources/GildedRose/GildedRose.swift +++ b/swift/Sources/GildedRose/GildedRose.swift @@ -1,13 +1,13 @@ public class GildedRose { var items: [Item] - + public init(items: [Item]) { self.items = items } - + 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].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 @@ -16,14 +16,14 @@ public class GildedRose { } else { 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 { items[i].quality = items[i].quality + 1 } } - + if items[i].sellIn < 6 { if items[i].quality < 50 { items[i].quality = items[i].quality + 1 @@ -32,11 +32,11 @@ public class GildedRose { } } } - + 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" { diff --git a/swift/Sources/GildedRose/Item.swift b/swift/Sources/GildedRose/Item.swift index d579d010..eb717bbb 100644 --- a/swift/Sources/GildedRose/Item.swift +++ b/swift/Sources/GildedRose/Item.swift @@ -2,7 +2,7 @@ public class Item { public var name: String public var sellIn: Int public var quality: Int - + public init(name: String, sellIn: Int, quality: Int) { self.name = name self.sellIn = sellIn @@ -12,6 +12,6 @@ public class Item { extension Item: CustomStringConvertible { public var description: String { - name + ", " + String(sellIn) + ", " + String(quality); + name + ", " + String(sellIn) + ", " + String(quality) } } diff --git a/swift/Sources/GildedRoseApp/main.swift b/swift/Sources/GildedRoseApp/main.swift index 78618ee4..edd7dc13 100644 --- a/swift/Sources/GildedRoseApp/main.swift +++ b/swift/Sources/GildedRoseApp/main.swift @@ -10,21 +10,22 @@ let items = [ Item(name: "Backstage passes to a TAFKAL80ETC concert", sellIn: 10, quality: 49), Item(name: "Backstage passes to a TAFKAL80ETC concert", sellIn: 5, quality: 49), // this conjured item does not work properly yet - Item(name: "Conjured Mana Cake", sellIn: 3, quality: 6)] + Item(name: "Conjured Mana Cake", sellIn: 3, quality: 6), +] -let app = GildedRose(items: items); +let app = GildedRose(items: items) -var days = 2; +var days = 2 if CommandLine.argc > 1 { days = Int(CommandLine.arguments[1])! + 1 } -for i in 0..