Beispiel #1
0
 def update_item(self):
     RegularItem.sell_in(self)
     Conjured.update_quality(self)
     RegularItem.check_quality(self)
Beispiel #2
0
 def quality_bigger_than_zero():
     milk = RegularItem("milk", 10, 5)
     milk.update_item()
     assert milk.updated_item() == ("milk", 9, 4)
Beispiel #3
0
 def update_item(self):
     RegularItem.sell_in(self)
     Backstage.update_quality(self)
     RegularItem.check_quality(self)
Beispiel #4
0
 def quality_less_than_zero():
     icecream = RegularItem("Icecream", 0, 5)
     icecream.update_item()
     assert icecream.updated_item() == ("Icecream", -1, 3)
Beispiel #5
0
 def update_item(self):
     AgedBrie.sell_in(self)
     AgedBrie.update_quality(self)
     RegularItem.check_quality(self)
Beispiel #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()
Beispiel #7
0
 def update_quality(self):
     if RegularItem.getSellIn(self) > 0:
         self.setQuality(+1)
     else:
         self.setQuality(+2)
     self.setSellIn()
Beispiel #8
0
 def __init__(self, name, sell_in, quality):
     RegularItem.__init__(self, name, sell_in, quality)