mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
commit
2235211d6f
7
go/gilded-rose_test.go
Normal file
7
go/gilded-rose_test.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_GildedRose(t *testing.T) {
|
||||
main()
|
||||
}
|
||||
75
go/glided-rose.go
Normal file
75
go/glided-rose.go
Normal file
@ -0,0 +1,75 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Item struct {
|
||||
name string
|
||||
sellIn, quality int
|
||||
}
|
||||
|
||||
var items = []Item{
|
||||
Item{"+5 Dexterity Vest", 10, 20},
|
||||
Item{"Aged Brie", 2, 0},
|
||||
Item{"Elixir of the Mongoose", 5, 7},
|
||||
Item{"Sulfuras, Hand of Ragnaros", 0, 80},
|
||||
Item{"Backstage passes to a TAFKAL80ETC concert", 15, 20},
|
||||
Item{"Conjured Mana Cake", 3, 6},
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("OMGHAI!")
|
||||
// fmt.Print(items)
|
||||
GlidedRose()
|
||||
}
|
||||
|
||||
func GlidedRose() {
|
||||
for i := 0; i < len(items); i++ {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
21
go/readme.md
Normal file
21
go/readme.md
Normal file
@ -0,0 +1,21 @@
|
||||
# GO Starter
|
||||
|
||||
- Run :
|
||||
|
||||
```shell
|
||||
go run gilded-rose.go
|
||||
```
|
||||
|
||||
- Run tests :
|
||||
|
||||
```shell
|
||||
go test
|
||||
```
|
||||
|
||||
- Run tests and coverage :
|
||||
|
||||
```shell
|
||||
go test -coverprofile=coverage.out
|
||||
|
||||
go tool cover -html=coverage.out
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user