Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/fi/
Binary file modified bin/fi/oulu/tol/sqat/GildedRose.class
Binary file not shown.
Binary file modified bin/fi/oulu/tol/sqat/Item.class
Binary file not shown.
Binary file modified bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class
Binary file not shown.
84 changes: 44 additions & 40 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

public class GildedRose {

private static final String SULFURAS = "Sulfuras, Hand of Ragnaros";
private static final String BACKSTAGE_PASS = "Backstage passes to a TAFKAL80ETC concert";
private static final String AGED_BRIE = "Aged Brie";
private static List<Item> items = null;

public List<Item> getItems() {
Expand All @@ -21,76 +24,77 @@ public GildedRose() {
}
public static void updateEndOfDay()
{
for (int i = 0; i < items.size(); i++)
for (Item item:items)
{
if ((!"Aged Brie".equals(items.get(i).getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName()))
{
if (items.get(i).getQuality() > 0)
{
if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName()))
{
items.get(i).setQuality(items.get(i).getQuality() - 1);
}
}
}
else
{
if (items.get(i).getQuality() < 50)
if ((AGED_BRIE.equals(item.getName())) || BACKSTAGE_PASS.equals(item.getName()))
{
if (!item.hasReachedMaximumQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.increaseQuality();

if ("Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName()))
if (BACKSTAGE_PASS.equals(item.getName()))
{
if (items.get(i).getSellIn() < 11)
if (item.getSellIn() < 11)
{
if (items.get(i).getQuality() < 50)
if (!item.hasReachedMaximumQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.increaseQuality();
}
}

if (items.get(i).getSellIn() < 6)
if (item.getSellIn() < 6)
{
if (items.get(i).getQuality() < 50)
if (!item.hasReachedMaximumQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.increaseQuality();
}
}
}
}
}
else
{
if (!item.hasReachedMaximumQuality())
{
if (!SULFURAS.equals(item.getName()))
{
item.decreaseQuality();
}
}
}

if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName()))
if (!SULFURAS.equals(item.getName()))
{
items.get(i).setSellIn(items.get(i).getSellIn() - 1);
item.decreaseSellIn();
}

if (items.get(i).getSellIn() < 0)
if (item.getSellIn() < 0)
{
if (!"Aged Brie".equals(items.get(i).getName()))
if (AGED_BRIE.equals(item.getName()))
{
if (!"Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName()))
{
if (items.get(i).getQuality() > 0)
{
if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName()))
{
items.get(i).setQuality(items.get(i).getQuality() - 1);
}
}
}
else
if (!item.hasReachedMaximumQuality())
{
items.get(i).setQuality(items.get(i).getQuality() - items.get(i).getQuality());
item.increaseQuality();
}
}
else
{
if (items.get(i).getQuality() < 50)
if (BACKSTAGE_PASS.equals(item.getName()))
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.setQuality(0);
}
else
{
if (!item.hasZeroQuality())
{
if (!SULFURAS.equals(item.getName()))
{
item.decreaseQuality();
}
}
}
}

}
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/fi/oulu/tol/sqat/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,24 @@ public int getQuality() {
public void setQuality(int quality) {
this.quality = quality;
}
public void decreaseQuality(){
this.quality--;
}
public void increaseQuality(){
this.quality++;
}
public void decreaseSellIn(){
this.sellIn--;
}
public boolean isExpired(){
return (this.sellIn < 0);
}
public boolean hasReachedMaximumQuality(){
return (this.quality == 50);
}
public boolean hasZeroQuality(){
return (this.quality < 1);
}

}

Loading