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/tests/GildedRoseTest.class
Binary file not shown.
116 changes: 88 additions & 28 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class GildedRose {

private static List<Item> items = null;
private static List<Item> items = new ArrayList<Item>();

/**
* @param args
Expand All @@ -15,93 +15,153 @@ public static void main(String[] args) {

System.out.println("OMGHAI!");

items = new ArrayList<Item>();

items.add(new Item("+5 Dexterity Vest", 10, 20));
items.add(new Item("Aged Brie", 2, 0));
items.add(new Item("Elixir of the Mongoose", 5, 7));
items.add(new Item("Sulfuras, Hand of Ragnaros", 0, 80));
items.add(new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20));
items.add(new Item("Conjured Mana Cake", 3, 6));

updateQuality();
updateEndOfDay();
}



public static void updateQuality()
public static void updateEndOfDay()
{
for (int i = 0; i < items.size(); i++)
{
if ((!"Aged Brie".equals(items.get(i).getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName()))
Item item = items.get(i);

if ((!"Aged Brie".equals(item.getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (items.get(i).getQuality() > 0)
if (HasZeroQuality(i) == false)
{
if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName()))
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
{
items.get(i).setQuality(items.get(i).getQuality() - 1);
DecreaseQuality(i);
}
}
}
else
{
if (items.get(i).getQuality() < 50)
if (HasReachedMaximumQuality(i) == false)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
IncreaseQuality(i);

if ("Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName()))
if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (items.get(i).getSellIn() < 11)
if (item.getSellIn() < 11)
{
if (items.get(i).getQuality() < 50)
if (HasReachedMaximumQuality(i) == false)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
IncreaseQuality(i);
}
}

if (items.get(i).getSellIn() < 6)
if (item.getSellIn() < 6)
{
if (items.get(i).getQuality() < 50)
if (HasReachedMaximumQuality(i) == false)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
IncreaseQuality(i);
}
}
}
}
}

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

if (items.get(i).getSellIn() < 0)
if (HasExpired(i) == false)
{
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 (!"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (items.get(i).getQuality() > 0)
if (item.getQuality() > 0)
{
if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName()))
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
{
items.get(i).setQuality(items.get(i).getQuality() - 1);
DecreaseQuality(i);
}
}
}
else
{
items.get(i).setQuality(items.get(i).getQuality() - items.get(i).getQuality());
item.setQuality(item.getQuality() - item.getQuality());
}
}
else
{
if (items.get(i).getQuality() < 50)
if (HasReachedMaximumQuality(i) == false)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
IncreaseQuality(i);
}
}
}
}
}



private static boolean HasExpired(int i) {
if (items.get(i).getSellIn() < 0){
return false;
}else{
return true;
}
}



private static boolean HasZeroQuality(int i) {
if(items.get(i).getQuality() > 0){
return false;
}else{
return true;
}
}



private static boolean HasReachedMaximumQuality(int i) {

if(items.get(i).getQuality() < 50){
return false;
}else{
return true;
}
}



public void addItem(Item item) {

items.add(item);

}



public List<Item> getItems() {

return items;
}

public static void DecreaseQuality(int i){
items.get(i).setQuality(items.get(i).getQuality() - 1);
}

public static void IncreaseQuality(int i){
items.get(i).setQuality(items.get(i).getQuality() + 1);
}

public static void DecreaseSellIn(int i){
items.get(i).setSellIn(items.get(i).getSellIn() - 1);
}

}
Loading