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.
210 changes: 134 additions & 76 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,88 +11,146 @@ public class GildedRose {
public List<Item> getItems() {
return items;
}

public void addItem(Item item) {
items.add(item);
}

public GildedRose() {
items = new ArrayList<Item>();
}
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()))
{
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)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);

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

if (items.get(i).getSellIn() < 6)
{
if (items.get(i).getQuality() < 50)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
}
}
}
}
}

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

if (items.get(i).getSellIn() < 0)
{
if (!"Aged Brie".equals(items.get(i).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
{
items.get(i).setQuality(items.get(i).getQuality() - items.get(i).getQuality());
}
}
else
{
if (items.get(i).getQuality() < 50)
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
}
}
}
}
}
public static void decreaseQuality(Item i){
i.setQuality(i.getQuality()-1);
}
public static void increaseQuality(Item i){
i.setQuality(i.getQuality()+1);
}
public static void decreaseSellIn(Item i){
i.setSellIn(i.getSellIn()-1);
}
public static boolean sellInLessThan11(Item i){

if(i.getSellIn() < 11){
return true;
}
return false;
}
public static boolean sellInLessThan6(Item i){
if(i.getSellIn() < 6){
return true;
}
return false;
}
public static boolean hasReachedMaximumQuality(Item i){
if(i.getQuality() < 50){
return true;
}
return false;
}
public static boolean hasZeroQuality(Item i){

if(i.getQuality() == 0){
return false;
}
return true;
}
public static boolean hasLessZeroSellIn(Item i){

if(i.getSellIn() < 0){
return true;
}
return false;
}
public static boolean isNotEqual(String name, Item i){
if(!name.equals(i.getName())){
return true;
}
return false;

}
public static boolean isEqual(String name, Item i){
if(name.equals(i.getName())){
return true;
}
return false;

}
public static void setQuality(Item i){
i.setQuality(i.getQuality() - i.getQuality());
}
public static void updateEndOfDay()
{
for (Item item:items)
{
if (isNotEqual("Aged Brie", item) && isNotEqual("Backstage passes to a TAFKAL80ETC concert", item))
{
if (hasZeroQuality(item))
{
if (isNotEqual("Sulfuras, Hand of Ragnaros", item))
{
decreaseQuality(item);
}
}
}
else
{
if (hasReachedMaximumQuality(item))
{
increaseQuality(item);
if (isEqual("Backstage passes to a TAFKAL80ETC concert", item))
{
if (sellInLessThan11(item))
{
if (hasReachedMaximumQuality(item))
{
increaseQuality(item);
}
}

if (sellInLessThan6(item))
{
if (hasReachedMaximumQuality(item))
{
increaseQuality(item);
}
}
}
}
}

if (isNotEqual("Sulfuras, Hand of Ragnaros", item))
{
decreaseSellIn(item);
}

if (hasLessZeroSellIn(item))
{
if (isNotEqual("Aged Brie", item))
{
if (isNotEqual("Backstage passes to a TAFKAL80ETC concert", item))
{
if (hasZeroQuality(item))
{
if (isNotEqual("Sulfuras, Hand of Ragnaros", item))
{
decreaseQuality(item);
}
}
}
else
{
setQuality(item);

}
}
else
{
if (hasReachedMaximumQuality(item)){
increaseQuality(item);
}
}
}
}
}

}
Loading