mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 09:11:39 +00:00
creating constants
This commit is contained in:
parent
457e9f43ba
commit
519eb43d5f
@ -1,6 +1,16 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
|
|
||||||
class GildedRose {
|
class GildedRose {
|
||||||
|
|
||||||
|
public static final String AGED_BRIE = "Aged Brie";
|
||||||
|
public static final String BACKSTAGE_PASSES = "Backstage passes to a TAFKAL80ETC concert";
|
||||||
|
public static final String SULFURAS = "Sulfuras, Hand of Ragnaros";
|
||||||
|
public static final int QUALITY_LEVEL_0 = 0;
|
||||||
|
public static final int QUALITY_LEVEL_50 = 50;
|
||||||
|
public static final int SELL_IN_DAY11 = 11;
|
||||||
|
public static final int SELL_IN_DAY6 = 6;
|
||||||
|
public static final int SELL_IN_DAY0 = 0;
|
||||||
|
|
||||||
Item[] items;
|
Item[] items;
|
||||||
|
|
||||||
public GildedRose(Item[] items) {
|
public GildedRose(Item[] items) {
|
||||||
@ -8,52 +18,58 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (Item item : items) {
|
||||||
if (!items[i].name.equals("Aged Brie")
|
// processing quality
|
||||||
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
if (!item.name.equals(AGED_BRIE) && !item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
if (items[i].quality > 0) {
|
if (item.quality > QUALITY_LEVEL_0) {
|
||||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
if (!item.name.equals(SULFURAS)) {
|
||||||
items[i].quality = items[i].quality - 1;
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (items[i].quality < 50) {
|
// processing quality
|
||||||
items[i].quality = items[i].quality + 1;
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
|
||||||
if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
// processing sell date
|
||||||
if (items[i].sellIn < 11) {
|
if (item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
if (items[i].quality < 50) {
|
|
||||||
items[i].quality = items[i].quality + 1;
|
if (item.sellIn < SELL_IN_DAY11) {
|
||||||
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items[i].sellIn < 6) {
|
if (item.sellIn < SELL_IN_DAY6) {
|
||||||
if (items[i].quality < 50) {
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
items[i].quality = items[i].quality + 1;
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
// processing sell date
|
||||||
items[i].sellIn = items[i].sellIn - 1;
|
if (!item.name.equals(SULFURAS)) {
|
||||||
|
item.sellIn = item.sellIn - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items[i].sellIn < 0) {
|
// processing sell date
|
||||||
if (!items[i].name.equals("Aged Brie")) {
|
if (item.sellIn < SELL_IN_DAY0) {
|
||||||
if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
if (!item.name.equals(AGED_BRIE)) {
|
||||||
if (items[i].quality > 0) {
|
if (!item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
// processing quality
|
||||||
items[i].quality = items[i].quality - 1;
|
if (item.quality > QUALITY_LEVEL_0) {
|
||||||
|
if (!item.name.equals(SULFURAS)) {
|
||||||
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
items[i].quality = items[i].quality - items[i].quality;
|
item.quality = QUALITY_LEVEL_0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (items[i].quality < 50) {
|
if (item.quality < QUALITY_LEVEL_50) {
|
||||||
items[i].quality = items[i].quality + 1;
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user