mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-14 22:21:20 +00:00
Iqbal Refactoring
This commit is contained in:
parent
596ae4de8b
commit
7812fa72f9
@ -1,40 +1,57 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from items import Item
|
from items import Item
|
||||||
|
|
||||||
class GildedRose(object):
|
class BaseItemUpdater:
|
||||||
|
def __init__(self, item):
|
||||||
|
self.item = item
|
||||||
|
|
||||||
def __init__(self, items):
|
def update(self):
|
||||||
self.items = items
|
self.update_sell_in()
|
||||||
|
self.update_quality()
|
||||||
|
|
||||||
|
def update_sell_in(self):
|
||||||
|
self.item.sell_in -= 1
|
||||||
|
|
||||||
def update_quality(self):
|
def update_quality(self):
|
||||||
for item in self.items:
|
if self.item.quality > 0:
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
self.item.quality -= 1
|
||||||
if item.quality > 0:
|
if self.item.sell_in < 0 and self.item.quality > 0:
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
self.item.quality -= 1
|
||||||
item.quality = item.quality - 1
|
|
||||||
else:
|
# class GildedRose(object):
|
||||||
if item.quality < 50:
|
|
||||||
item.quality = item.quality + 1
|
# def __init__(self, items):
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert":
|
# self.items = items
|
||||||
if item.sell_in < 11:
|
|
||||||
if item.quality < 50:
|
# def update_quality(self):
|
||||||
item.quality = item.quality + 1
|
# for item in self.items:
|
||||||
if item.sell_in < 6:
|
# if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
||||||
if item.quality < 50:
|
# if item.quality > 0:
|
||||||
item.quality = item.quality + 1
|
# if item.name != "Sulfuras, Hand of Ragnaros":
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
# item.quality = item.quality - 1
|
||||||
item.sell_in = item.sell_in - 1
|
# else:
|
||||||
if item.sell_in < 0:
|
# if item.quality < 50:
|
||||||
if item.name != "Aged Brie":
|
# item.quality = item.quality + 1
|
||||||
if item.name != "Backstage passes to a TAFKAL80ETC concert":
|
# if item.name == "Backstage passes to a TAFKAL80ETC concert":
|
||||||
if item.quality > 0:
|
# if item.sell_in < 11:
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
# if item.quality < 50:
|
||||||
item.quality = item.quality - 1
|
# item.quality = item.quality + 1
|
||||||
else:
|
# if item.sell_in < 6:
|
||||||
item.quality = item.quality - item.quality
|
# if item.quality < 50:
|
||||||
else:
|
# item.quality = item.quality + 1
|
||||||
if item.quality < 50:
|
# if item.name != "Sulfuras, Hand of Ragnaros":
|
||||||
item.quality = item.quality + 1
|
# item.sell_in = item.sell_in - 1
|
||||||
|
# if item.sell_in < 0:
|
||||||
|
# if item.name != "Aged Brie":
|
||||||
|
# if item.name != "Backstage passes to a TAFKAL80ETC concert":
|
||||||
|
# if item.quality > 0:
|
||||||
|
# if item.name != "Sulfuras, Hand of Ragnaros":
|
||||||
|
# item.quality = item.quality - 1
|
||||||
|
# else:
|
||||||
|
# item.quality = item.quality - item.quality
|
||||||
|
# else:
|
||||||
|
# if item.quality < 50:
|
||||||
|
# item.quality = item.quality + 1
|
||||||
|
|
||||||
|
|
||||||
# class Item:
|
# class Item:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user