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 5 done #51

Open
wants to merge 1 commit into
base: master
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.
71 changes: 43 additions & 28 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@
public class GildedRose {

private static List<Item> items = null;

/**
* @param args
*/

public GildedRose() {
items = new ArrayList<Item>();
}

public List<Item> getItems() {
return items;
}

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

public static void main(String[] args) {

System.out.println("OMGHAI!");
Expand All @@ -23,85 +36,87 @@ public static void main(String[] args) {
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++)
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.zeroQuality())
{
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.reduceQuality();
}
}
}
else
{
if (items.get(i).getQuality() < 50)
if (!item.maxQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.increaseQuality();

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

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

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.reduceSellIn();
}

if (items.get(i).getSellIn() < 0)
if (item.zeroSellIn())
{
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.zeroQuality())
{
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.reduceQuality();
}
}
}
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.maxQuality())
{
items.get(i).setQuality(items.get(i).getQuality() + 1);
item.increaseQuality();
}
}
}
}
}



}
37 changes: 37 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,42 @@ public int getQuality() {
public void setQuality(int quality) {
this.quality = quality;
}

public boolean zeroQuality() {
// TODO Auto-generated method stub
if (quality <= 0)
return true;
return false;
}

public boolean maxQuality() {
// TODO Auto-generated method stub
if (quality >= 50)
return true;
return false;
}

public void reduceQuality() {
// TODO Auto-generated method stub
quality--;
}

public void increaseQuality() {
// TODO Auto-generated method stub
quality++;

}

public void reduceSellIn() {
// TODO Auto-generated method stub
sellIn--;
}

public boolean zeroSellIn() {
// TODO Auto-generated method stub
if (sellIn < 0)
return true;
return false;
}
}

Loading