Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment completed #61

Open
wants to merge 6 commits into
base: testing
Choose a base branch
from
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.
127 changes: 59 additions & 68 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,76 +23,67 @@ 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 (item.isSpecial())/*item string is in 'special item' list*/
{
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 ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (item.getSellIn() > 10)
{
if (!item.isMaximumQuality())
{
item.increaseQuality(1);
}
}
else if (item.getSellIn() <= 10 && item.getSellIn() > 5)
{
if (!item.isMaximumQuality())
{
item.increaseQuality(2);
}
}
else if (item.getSellIn() <= 5 && item.getSellIn() > 0)
{
if (!item.isMaximumQuality())
{
item.increaseQuality(3);
}
}
else if (item.HasExpired())
{
item.setQuality(0);
}
}
else if ("Aged Brie".equals(item.getName()))
{
if(!item.isMaximumQuality() && item.getSellIn() > 0){
item.increaseQuality(1);
}else if (!item.isMaximumQuality() && item.getSellIn() <= 0){
item.increaseQuality(2);
}
}

item.decreaseSellIn();

if ("Sulfuras, Hand of Ragnaros".equals(item.getName()))/*if item is Sulfuras, ignore everything above, set Sulfuras stats*/
{
item.setSulfuras();

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);
}
}
}
}
}
}
/*otherwise item is normal*/
else{
if (item.getSellIn() > 0){
item.decreaseQuality(1);
item.decreaseSellIn();
}else if (item.getSellIn() <= 0){
item.decreaseQuality(2);
item.decreaseSellIn();
}
}
}
}


}
43 changes: 43 additions & 0 deletions src/fi/oulu/tol/sqat/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,49 @@ public Item(String name, int sellIn, int quality) {
this.setSellIn(sellIn);
this.setQuality(quality);
}
public boolean HasExpired (){
if (sellIn<=0){
return true;}
else return false;
}
public boolean isMaximumQuality(){
if (quality >= 50)
{
quality = 50;
return true;
}
else return false;
}
public boolean hasZeroQuality(){
return true;
}
public boolean isSpecial(){
/*lists some special items*/
if (name=="Backstage passes to a TAFKAL80ETC concert"
|| name == "Aged Brie"
|| name == "Sulfuras, Hand of Ragnaros")
{return true;}
else return false;
}


public void decreaseQuality(int x){
quality = quality - x;
}

public void increaseQuality(int x){
quality = quality + x;
}

public void decreaseSellIn(){
/*sellIn only ever decreases by 1*/
sellIn = sellIn - 1;
}

public void setSulfuras(){
quality = 80;
sellIn = 0;
}

/* Generated getter and setter code */
public String getName() {
Expand Down
Loading