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.
202 changes: 95 additions & 107 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
@@ -1,107 +1,95 @@
package fi.oulu.tol.sqat;

import java.util.ArrayList;
import java.util.List;


public class GildedRose {

private static List<Item> items = null;

/**
* @param args
*/
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();
}



public static void updateQuality()
{
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);
}
}
}
}
}

}
package fi.oulu.tol.sqat;

import java.util.ArrayList;
import java.util.List;


public class GildedRose {

private static List<Item> items = null;

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(Item item:items)
{
if ((!"Aged Brie".equals(item.getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (!item.hasZeroQuality())
{
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
{
item.decreaseQuality();
}
}
}
else
{
if (!item.hasReachedMaximumQuality())
{
item.increaseQuality();
if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (item.getSellIn() < 11)
{
if (!item.hasReachedMaximumQuality())
{
item.increaseQuality();
}

if (item.getSellIn() < 6)
{
if (!item.hasReachedMaximumQuality())
{
item.increaseQuality();
}
}
}
}
}

if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
{
item.decreaseSellIn();
}

if (item.isExpired())
{
if (!"Aged Brie".equals(item.getName()))
{
if (!"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (!item.hasZeroQuality())// change
{
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
{
item.decreaseQuality();
}
}
}
else
{
item.setQuality(item.getQuality() - item.getQuality());
}
}
else
{
if (!item.hasReachedMaximumQuality())
{
item.increaseQuality();
}
}
}
}
}
}
92 changes: 57 additions & 35 deletions src/fi/oulu/tol/sqat/Item.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,57 @@
package fi.oulu.tol.sqat;


public class Item {
public String name;
public int sellIn;
public int quality;

public Item(String name, int sellIn, int quality) {
this.setName(name);
this.setSellIn(sellIn);
this.setQuality(quality);
}

/* Generated getter and setter code */
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSellIn() {
return sellIn;
}
public void setSellIn(int sellIn) {
this.sellIn = sellIn;
}
public int getQuality() {
return quality;
}
public void setQuality(int quality) {
this.quality = quality;
}
}

package fi.oulu.tol.sqat;


public class Item {
public String name;
public int sellIn;
public int quality;
private static final int MAX_QUALITY =50;

public Item(String name, int sellIn, int quality) {
this.setName(name);
this.setSellIn(sellIn);
this.setQuality(quality);
}

/* Generated getter and setter code */
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSellIn() {
return sellIn;
}
public void setSellIn(int sellIn) {
this.sellIn = sellIn;
}
public int getQuality() {
return quality;
}
public void setQuality(int quality) {
this.quality = quality;
}
public void decreaseQuality(){
setQuality(getQuality() -1 );
}
public void increaseQuality(){
setQuality(getQuality() +1 );
}
public void decreaseSellIn(){
setSellIn(getSellIn() -1);
}
public void increaseSellIn(){
setSellIn(getSellIn() +1);
}
public boolean isExpired(){
return getSellIn() <0;
}
public boolean hasZeroQuality(){
return getQuality() == 0;
}
public boolean hasReachedMaximumQuality(){
return getQuality() == MAX_QUALITY;
}
}

Loading