mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
Dont get item from array every time
This commit is contained in:
parent
f1a9242aac
commit
8b94d335e8
@ -15,51 +15,52 @@ class GildedRose {
|
||||
|
||||
public void updateQuality() {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (!items[i].name.equals(ITEM_AGED_BRIE)
|
||||
&& !items[i].name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (items[i].quality > MIN_QUALITY_LEVEL) {
|
||||
if (!items[i].name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
items[i].quality = items[i].quality - 1;
|
||||
final Item currentItem = items[i];
|
||||
if (!currentItem.name.equals(ITEM_AGED_BRIE)
|
||||
&& !currentItem.name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (currentItem.quality > MIN_QUALITY_LEVEL) {
|
||||
if (!currentItem.name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
currentItem.quality = currentItem.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (items[i].quality < MAX_QUALITY_LEVEL) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
|
||||
if (items[i].name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (items[i].sellIn < 11) {
|
||||
if (items[i].quality < MAX_QUALITY_LEVEL) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
if (currentItem.name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (currentItem.sellIn < 11) {
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (items[i].sellIn < 6) {
|
||||
if (items[i].quality < MAX_QUALITY_LEVEL) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
if (currentItem.sellIn < 6) {
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!items[i].name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
items[i].sellIn = items[i].sellIn - 1;
|
||||
if (!currentItem.name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
currentItem.sellIn = currentItem.sellIn - 1;
|
||||
}
|
||||
|
||||
if (items[i].sellIn < 0) {
|
||||
if (!items[i].name.equals(ITEM_AGED_BRIE)) {
|
||||
if (!items[i].name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (items[i].quality > MIN_QUALITY_LEVEL) {
|
||||
if (!items[i].name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
items[i].quality = items[i].quality - 1;
|
||||
if (currentItem.sellIn < 0) {
|
||||
if (!currentItem.name.equals(ITEM_AGED_BRIE)) {
|
||||
if (!currentItem.name.equals(ITEM_BACKSTAGE_PASSES)) {
|
||||
if (currentItem.quality > MIN_QUALITY_LEVEL) {
|
||||
if (!currentItem.name.equals(ITEM_SULFURAS_HAND_OF_RAGNAROS)) {
|
||||
currentItem.quality = currentItem.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
items[i].quality = items[i].quality - items[i].quality;
|
||||
currentItem.quality = currentItem.quality - currentItem.quality;
|
||||
}
|
||||
} else {
|
||||
if (items[i].quality < MAX_QUALITY_LEVEL) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
if (currentItem.quality < MAX_QUALITY_LEVEL) {
|
||||
currentItem.quality = currentItem.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user