logic nesting removed

This commit is contained in:
Sallah Kokaina 2019-11-01 19:41:57 +01:00
parent 783a62bb3f
commit 58220c2358
2 changed files with 26 additions and 26 deletions

View File

@ -24,10 +24,10 @@
## Technical Issues, with a balanced priority
-[x] item names are hardcoded
-[x] items are identified by the name in a hardcoded way
-[ ] nested logic
-[x] nested logic
-[x] long method
-[ ] plain logic
-[ ] complex operations
-[x] plain logic
-[x] complex operations
-[x] Item properties are public
-[x] multiple access by index
@ -38,6 +38,6 @@
-[x] extract methods
-[x] extract boolean methods
-[x] encapsulate methods
-[ ] isolate specific logics
-[x] isolate specific logics
-[x] move specific logic to backstage
-[x] move specific logic of sulfuras

View File

@ -14,37 +14,37 @@ class GildedRose {
public void updateQuality() {
for (int i = 0; i < items.length; i++) {
final Item item = items[i];
item.updateSellIn();
if(item.name.equals(Brie.BRIE)){
updateBrieQuality(item);
}else if (item.name.equals(Backstage.BACKSTAGE)){
updateBackstageQuality(item);
}else if (!item.name.equals(Sulfuras.SULFURAS)){
updateItemQuality(item);
}
else if (!item.name.equals(Sulfuras.SULFURAS)){
if (!item.name.equals(Backstage.BACKSTAGE)) {
if (item.quality > 0 && !item.name.equals(Sulfuras.SULFURAS)) {
item.decreaseQuality();
}
}
else {
if (item.quality < 50) {
item.increaseQuality();
}
}
}
}
if (item.sellIn < 0) {
if (!item.name.equals(Backstage.BACKSTAGE)) {
if (!item.name.equals(Sulfuras.SULFURAS) && item.quality > 0) {
item.decreaseQuality();
}
} else {
item.quality = 0;
}
private void updateItemQuality(Item item) {
if (!item.name.equals(Backstage.BACKSTAGE)) {
if (item.quality > 0 ) {
item.decreaseQuality();
}
}
else {
if (item.quality < 50) {
item.increaseQuality();
}
}
if (item.sellIn < 0) {
if (!item.name.equals(Backstage.BACKSTAGE)) {
if ( item.quality > 0) {
item.decreaseQuality();
}
} else {
item.quality = 0;
}
}
}