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

finished #46

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/tests/GildedRoseTest.class
Binary file not shown.
219 changes: 130 additions & 89 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,96 +12,137 @@ public class GildedRose {
* @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();
}

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(Item item:items) {
if (!compareName("Aged Brie", item) && !compareName("Backstage passes to a TAFKAL80ETC concert", item))
{
if (hasMoreThanZeroQuality(item))
{
decrement1QualityIfSultaras(item);
}
}
else
{
if (hasNotReachedMaximumQuality(item))
{
increment1Quality(item);

if (compareName("Backstage passes to a TAFKAL80ETC concert", item))
{
if (hasLessThanElevenSellIn(item))
{
if (hasNotReachedMaximumQuality(item))
{
increment1Quality(item);
}
}

if (hasLessThanSixSellIn(item))
{
if (hasNotReachedMaximumQuality(item))
{
increment1Quality(item);
}
}
}
}
}

decrement1SellInIfSultaras(item);


if (hasLessThanZeroSellIn(item))
{
if (!compareName("Aged Brie", item))
{
if (!compareName("Backstage passes to a TAFKAL80ETC concert", item)) {
if (hasMoreThanZeroQuality(item))
{
decrement1QualityIfSultaras(item);

}
}
else
{
hasZeroQuality(item);
}
}
else
{
if (hasNotReachedMaximumQuality(item))
increment1Quality(item);
}
}
}
}

public static boolean compareName(String nameA,Item item){
return nameA.equals(item.getName());
}
public static void decrement1QualityIfSultaras(Item item){

if (!compareName("Sulfuras, Hand of Ragnaros", item))
{
item.setQuality(item.getQuality() - 1);

}
}
public static void decrement1SellInIfSultaras(Item item){

if (!compareName("Sulfuras, Hand of Ragnaros", item))
{
item.setSellIn(item.getSellIn() - 1);
}
}
public static void increment1Quality(Item item){

item.setQuality(item.getQuality() + 1);

}
public static boolean hasNotReachedMaximumQuality(Item item){
return item.getQuality() < 50;

}
public static void hasZeroQuality(Item item){
item.setQuality(item.getQuality() - item.getQuality());

}
public static boolean hasMoreThanZeroQuality(Item item){
return item.getQuality() > 0;
}
public static boolean hasLessThanZeroSellIn(Item item){
return item.getSellIn() < 0;
}


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);
}
}
}
}
}
public static boolean hasLessThanElevenSellIn(Item item){
return item.getSellIn() < 11;
}
public static boolean hasLessThanSixSellIn(Item item){
return item.getSellIn() < 6;
}
public void addItem(Item item){
items = new ArrayList<Item>();
items.add(item);
}
public static List<Item> getItems() {
return items;
}

}
Loading