mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 12:22:12 +00:00
updated these versions to more closely match the original C#
This commit is contained in:
parent
2e3386ab13
commit
4dab932c94
@ -1,8 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
class GildedRose(object):
|
||||||
|
|
||||||
def update_quality(items):
|
def __init__(self, items):
|
||||||
for item in items:
|
self.items = items
|
||||||
|
|
||||||
|
def update_quality(self):
|
||||||
|
for item in self.items:
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
||||||
if item.quality > 0:
|
if item.quality > 0:
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
if item.name != "Sulfuras, Hand of Ragnaros":
|
||||||
@ -30,7 +34,6 @@ def update_quality(items):
|
|||||||
else:
|
else:
|
||||||
if item.quality < 50:
|
if item.quality < 50:
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1
|
||||||
return items
|
|
||||||
|
|
||||||
|
|
||||||
class Item:
|
class Item:
|
||||||
|
|||||||
@ -1,14 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import unittest
|
import unittest
|
||||||
from gilded_rose import Item, update_quality
|
|
||||||
|
from gilded_rose import Item, GildedRose
|
||||||
|
|
||||||
|
|
||||||
class GildedRoseTest(unittest.TestCase):
|
class GildedRoseTest(unittest.TestCase):
|
||||||
def test_foo(self):
|
def test_foo(self):
|
||||||
items = [Item("foo", 0, 0)]
|
items = [Item("foo", 0, 0)]
|
||||||
update_quality(items)
|
gilded_rose = GildedRose(items)
|
||||||
|
gilded_rose.update_quality()
|
||||||
self.assertEquals("fixme", items[0].name)
|
self.assertEquals("fixme", items[0].name)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
|
|
||||||
class GildedRose
|
class GildedRose
|
||||||
def update_quality(items)
|
def initialize(items)
|
||||||
items.each do |item|
|
@items = items
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_quality()
|
||||||
|
@items.each do |item|
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
if item.quality > 0
|
if item.quality > 0
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||||
@ -46,7 +50,6 @@ class GildedRose
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
items
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ describe GildedRose do
|
|||||||
describe "#update_quality" do
|
describe "#update_quality" do
|
||||||
it "does not change the name" do
|
it "does not change the name" do
|
||||||
items = [Item.new("foo", 0, 0)]
|
items = [Item.new("foo", 0, 0)]
|
||||||
GildedRose.new().update_quality(items)
|
GildedRose.new(items).update_quality()
|
||||||
items[0].name.should == "fixme"
|
items[0].name.should == "fixme"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user