fixed directory structure

This commit is contained in:
Ton van Bart committed 2016-12-01 09:45:34 +01:00
1 parent dae358a131
commit 40e7ea75c6
4 files changed
+147

No files matched your search

@@ -0,0 +1,72 @@
package com.gildedrose;
class GildedRose {
Item[] items;
public GildedRose(Item[] items) {
this.items = items;
}
public void updateQuality() {
for (int i = 0; i < items.length; i++) {
if (!items[i].name.equals("Aged Brie")
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
if (items[i].quality > 0) {
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
items[i].quality = items[i].quality - 1;
}
}
} else increaseQuality(items[i]);
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
items[i].sellIn = items[i].sellIn - 1;
}
if (items[i].sellIn < 0) {
handlePastSellin(items[i]);
}
}
}
private void handlePastSellin(Item item) {
if (!item.name.equals("Aged Brie")) {
if (!item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
if (item.quality > 0) {
if (!item.name.equals("Sulfuras, Hand of Ragnaros")) {
item.quality = item.quality - 1;
}
}
} else {
item.quality = 0;
}
} else {
if (item.quality < 50) {
item.quality = item.quality + 1;
}
}
}
private void increaseQuality(Item item) {
if (item.quality < 50) {
item.quality = item.quality + 1;
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
handleBackstagePass(item);
}
}
}
private void handleBackstagePass(Item backstagePass) {
if (backstagePass.sellIn < 11) {
if (backstagePass.quality < 50) {
backstagePass.quality = backstagePass.quality + 1;
}
}
if (backstagePass.sellIn < 6) {
if (backstagePass.quality < 50) {
backstagePass.quality = backstagePass.quality + 1;
}
}
}
}
@@ -0,0 +1,21 @@
package com.gildedrose;
public class Item {
public String name;
public int sellIn;
public int quality;
public Item(String name, int sellIn, int quality) {
this.name = name;
this.sellIn = sellIn;
this.quality = quality;
}
@Override
public String toString() {
return this.name + ", " + this.sellIn + ", " + this.quality;
}
}