示例#1
0
 def update_item(self):
     RegularItem.sell_in(self)
     Conjured.update_quality(self)
     RegularItem.check_quality(self)
示例#2
0
 def quality_bigger_than_zero():
     milk = RegularItem("milk", 10, 5)
     milk.update_item()
     assert milk.updated_item() == ("milk", 9, 4)
示例#3
0
 def update_item(self):
     RegularItem.sell_in(self)
     Backstage.update_quality(self)
     RegularItem.check_quality(self)
示例#4
0
 def quality_less_than_zero():
     icecream = RegularItem("Icecream", 0, 5)
     icecream.update_item()
     assert icecream.updated_item() == ("Icecream", -1, 3)
示例#5
0
 def update_item(self):
     AgedBrie.sell_in(self)
     AgedBrie.update_quality(self)
     RegularItem.check_quality(self)
示例#6
0
class GildedRose(object):
    def __init__(self, items):
        self.items = items

    def update_quality(self):
        for day in range(1, 32):
            print("-------------- day ", day, "--------------")
            for item in self.items:
                print(item)
                item.update_item()

    def updated_items(self):
        return self.items


if __name__ == "__main__":
    stock = GildedRose([
        RegularItem("+ 5 Dexterity Vest", 10, 20),
        AgedBrie("Aged Brie", 2, 0),
        RegularItem("Elixir of the Mongoose", 5, 7),
        Sulfuras("Sulfuras, Hand of Ragnaros", 0, 80),
        Sulfuras("Sulfuras, Hand of Ragnaros", 0, 80),
        Backstage("Backstage passes to a TAFKAL80ETC concert", 15, 20),
        Backstage("Backstage passes to a TAFKAL80ETC concert", 10, 49),
        Backstage("Backstage passes to a TAFKAL80ETC concert", 5, 49),
        Conjured("Conjured Mana Cake", 3, 6)
    ])

    stock.update_quality()
示例#7
0
 def update_quality(self):
     if RegularItem.getSellIn(self) > 0:
         self.setQuality(+1)
     else:
         self.setQuality(+2)
     self.setSellIn()
示例#8
0
 def __init__(self, name, sell_in, quality):
     RegularItem.__init__(self, name, sell_in, quality)