mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
added code needed for test fixture - ie toString methods and main method
This commit is contained in:
parent
8da58f6dd1
commit
6f7efa40eb
16
GildedRose/Java/GildedRose.java
Normal file → Executable file
16
GildedRose/Java/GildedRose.java
Normal file → Executable file
@ -5,22 +5,6 @@ class GildedRose {
|
|||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("OMGHAI!");
|
|
||||||
|
|
||||||
Item[] items = new Item[] { new Item("+5 Dexterity Vest", 10, 20),
|
|
||||||
new Item("Aged Brie", 2, 0),
|
|
||||||
new Item("Elixir of the Mongoose", 5, 7),
|
|
||||||
new Item("Sulfuras, Hand of Ragnaros", 0, 80),
|
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
|
||||||
new Item("Conjured Mana Cake", 3, 6) };
|
|
||||||
|
|
||||||
GildedRose app = new GildedRose(items);
|
|
||||||
|
|
||||||
app.updateQuality();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
if (items[i].name != "Aged Brie"
|
if (items[i].name != "Aged Brie"
|
||||||
|
|||||||
4
GildedRose/Java/Item.java
Normal file → Executable file
4
GildedRose/Java/Item.java
Normal file → Executable file
@ -11,4 +11,8 @@ public class Item {
|
|||||||
this.sellIn = sellIn;
|
this.sellIn = sellIn;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.name + ", " + this.sellIn + ", " + this.quality;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
GildedRose/python/gilded_rose.py
Normal file → Executable file
17
GildedRose/python/gilded_rose.py
Normal file → Executable file
@ -36,7 +36,11 @@ class Item:
|
|||||||
self.sell_in = sell_in
|
self.sell_in = sell_in
|
||||||
self.quality = quality
|
self.quality = quality
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "%s, %s, %s" % (self.name, self.sell_in, self.quality)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print ("OMGHAI!")
|
||||||
items = [
|
items = [
|
||||||
Item(name="+5 Dexterity Vest", sell_in=10, quality=20),
|
Item(name="+5 Dexterity Vest", sell_in=10, quality=20),
|
||||||
Item(name="Aged Brie", sell_in=2, quality=0),
|
Item(name="Aged Brie", sell_in=2, quality=0),
|
||||||
@ -45,4 +49,15 @@ if __name__ == "__main__":
|
|||||||
Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20),
|
Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20),
|
||||||
Item(name="Conjured Mana Cake", sell_in=3, quality=6),
|
Item(name="Conjured Mana Cake", sell_in=3, quality=6),
|
||||||
]
|
]
|
||||||
update_quality(items)
|
|
||||||
|
days = 2
|
||||||
|
import sys
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
days = int(sys.argv[1]) + 1
|
||||||
|
for day in range(days):
|
||||||
|
print("-------- day %s --------" % day)
|
||||||
|
print("name, sellIn, quality")
|
||||||
|
for item in items:
|
||||||
|
print(item)
|
||||||
|
print("")
|
||||||
|
update_quality(items)
|
||||||
Loading…
Reference in New Issue
Block a user