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

Testing #56

Open
wants to merge 2 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.
50 changes: 25 additions & 25 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,74 +21,74 @@ 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 ((!"Aged Brie".equals(item.getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
{
if (items.get(i).getQuality() > 0)
if (item.hasPositiveQuality())
{
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);
item.setQuality(item.getQuality() - 1);
}
}
}
else
{
if (items.get(i).getQuality() < 50)
if (item.canIncreaseQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.setQuality(item.getQuality() + 1);

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 (item.canIncreaseQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.setQuality(item.getQuality() + 1);
}
}

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

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);
item.setSellIn(item.getSellIn() - 1);
}

if (items.get(i).getSellIn() < 0)
if (item.hasExpired())
{
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.hasPositiveQuality())
{
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);
item.setQuality(item.getQuality() - 1);
}
}
}
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 (item.canIncreaseQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.setQuality(item.getQuality() + 1);
}
}
}
Expand Down
24 changes: 24 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,29 @@ public int getQuality() {
public void setQuality(int quality) {
this.quality = quality;
}
public void decreaseQuality(int amount) {
this.quality -= amount;
}
public void increaseQuality(int amount) {
this.quality += amount;
}
public void increaseSellIn(int amount) {
this.sellIn += amount;
}
public void decreaseSellIn(int amount) {
this.sellIn -= amount;
}
public boolean hasPositiveQuality() {
if (this.quality > 0) return true;
return false;
}
public boolean canIncreaseQuality() {
if (this.quality < 50) return true;
return false;
}
public boolean hasExpired() {
if (this.sellIn < 0) return true;
return false;
}
}

Loading