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;
|
||||
|
||||
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;
|
||||
|
||||
public GildedRose(Item[] items) {
|
||||
@ -8,52 +18,58 @@ class GildedRose {
|
||||
}
|
||||
|
||||
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;
|
||||
for (Item item : items) {
|
||||
// processing quality
|
||||
if (!item.name.equals(AGED_BRIE) && !item.name.equals(BACKSTAGE_PASSES)) {
|
||||
if (item.quality > QUALITY_LEVEL_0) {
|
||||
if (!item.name.equals(SULFURAS)) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
// processing quality
|
||||
if (item.quality < QUALITY_LEVEL_50) {
|
||||
item.quality = item.quality + 1;
|
||||
|
||||
if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (items[i].sellIn < 11) {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
// processing sell date
|
||||
if (item.name.equals(BACKSTAGE_PASSES)) {
|
||||
|
||||
if (item.sellIn < SELL_IN_DAY11) {
|
||||
if (item.quality < QUALITY_LEVEL_50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (items[i].sellIn < 6) {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
if (item.sellIn < SELL_IN_DAY6) {
|
||||
if (item.quality < QUALITY_LEVEL_50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
items[i].sellIn = items[i].sellIn - 1;
|
||||
// processing sell date
|
||||
if (!item.name.equals(SULFURAS)) {
|
||||
item.sellIn = item.sellIn - 1;
|
||||
}
|
||||
|
||||
if (items[i].sellIn < 0) {
|
||||
if (!items[i].name.equals("Aged Brie")) {
|
||||
if (!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;
|
||||
// processing sell date
|
||||
if (item.sellIn < SELL_IN_DAY0) {
|
||||
if (!item.name.equals(AGED_BRIE)) {
|
||||
if (!item.name.equals(BACKSTAGE_PASSES)) {
|
||||
// processing quality
|
||||
if (item.quality > QUALITY_LEVEL_0) {
|
||||
if (!item.name.equals(SULFURAS)) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
items[i].quality = items[i].quality - items[i].quality;
|
||||
item.quality = QUALITY_LEVEL_0;
|
||||
}
|
||||
} else {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
if (item.quality < QUALITY_LEVEL_50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user