mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
Delete swift directory
This commit is contained in:
parent
3b26de6594
commit
3af29a7b03
7
swift/.gitignore
vendored
7
swift/.gitignore
vendored
@ -1,7 +0,0 @@
|
|||||||
.DS_Store
|
|
||||||
/.build
|
|
||||||
/Packages
|
|
||||||
/*.xcodeproj
|
|
||||||
xcuserdata/
|
|
||||||
DerivedData/
|
|
||||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
// swift-tools-version:5.5
|
|
||||||
|
|
||||||
import PackageDescription
|
|
||||||
|
|
||||||
let package = Package(
|
|
||||||
name: "GildedRose",
|
|
||||||
products: [
|
|
||||||
.library(
|
|
||||||
name: "GildedRose",
|
|
||||||
targets: ["GildedRose"]
|
|
||||||
),
|
|
||||||
],
|
|
||||||
targets: [
|
|
||||||
.target(
|
|
||||||
name: "GildedRose",
|
|
||||||
dependencies: []
|
|
||||||
),
|
|
||||||
.target(
|
|
||||||
name: "GildedRoseApp",
|
|
||||||
dependencies: ["GildedRose"]
|
|
||||||
),
|
|
||||||
.testTarget(
|
|
||||||
name: "GildedRoseTests",
|
|
||||||
dependencies: ["GildedRose"]
|
|
||||||
),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
## Build and test using any of the following
|
|
||||||
|
|
||||||
Command line:
|
|
||||||
- `swift test`
|
|
||||||
|
|
||||||
Xcode:
|
|
||||||
- Open this "swift" folder to open package
|
|
||||||
- In the Xcode menu, select Product > Test to run tests
|
|
||||||
|
|
||||||
AppCode:
|
|
||||||
- Open this "swift" folder to open package
|
|
||||||
- Select "GildedRoseTests" configuration and run
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
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].quality > 0 {
|
|
||||||
if items[i].name != "Sulfuras, Hand of Ragnaros" {
|
|
||||||
items[i].quality = items[i].quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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" {
|
|
||||||
items[i].quality = items[i].quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
items[i].quality = items[i].quality - items[i].quality
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if items[i].quality < 50 {
|
|
||||||
items[i].quality = items[i].quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
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
|
|
||||||
self.quality = quality
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension Item: CustomStringConvertible {
|
|
||||||
public var description: String {
|
|
||||||
name + ", " + String(sellIn) + ", " + String(quality)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
import GildedRose
|
|
||||||
|
|
||||||
let items = [
|
|
||||||
Item(name: "+5 Dexterity Vest", sellIn: 10, quality: 20),
|
|
||||||
Item(name: "Aged Brie", sellIn: 2, quality: 0),
|
|
||||||
Item(name: "Elixir of the Mongoose", sellIn: 5, quality: 7),
|
|
||||||
Item(name: "Sulfuras, Hand of Ragnaros", sellIn: 0, quality: 80),
|
|
||||||
Item(name: "Sulfuras, Hand of Ragnaros", sellIn: -1, quality: 80),
|
|
||||||
Item(name: "Backstage passes to a TAFKAL80ETC concert", sellIn: 15, quality: 20),
|
|
||||||
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),
|
|
||||||
]
|
|
||||||
|
|
||||||
let app = GildedRose(items: items)
|
|
||||||
|
|
||||||
var days = 2
|
|
||||||
if CommandLine.argc > 1 {
|
|
||||||
days = Int(CommandLine.arguments[1])! + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in 0 ..< days {
|
|
||||||
print("-------- day \(i) --------")
|
|
||||||
print("name, sellIn, quality")
|
|
||||||
for item in items {
|
|
||||||
print(item)
|
|
||||||
}
|
|
||||||
print("")
|
|
||||||
app.updateQuality()
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
@testable import GildedRose
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class GildedRoseTests: XCTestCase {
|
|
||||||
func testFoo() throws {
|
|
||||||
let items = [Item(name: "foo", sellIn: 0, quality: 0)]
|
|
||||||
let app = GildedRose(items: items)
|
|
||||||
app.updateQuality()
|
|
||||||
XCTAssertEqual(app.items[0].name, "fixme")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user