mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
logic nesting removed
This commit is contained in:
parent
783a62bb3f
commit
58220c2358
@ -24,10 +24,10 @@
|
|||||||
## Technical Issues, with a balanced priority
|
## Technical Issues, with a balanced priority
|
||||||
-[x] item names are hardcoded
|
-[x] item names are hardcoded
|
||||||
-[x] items are identified by the name in a hardcoded way
|
-[x] items are identified by the name in a hardcoded way
|
||||||
-[ ] nested logic
|
-[x] nested logic
|
||||||
-[x] long method
|
-[x] long method
|
||||||
-[ ] plain logic
|
-[x] plain logic
|
||||||
-[ ] complex operations
|
-[x] complex operations
|
||||||
-[x] Item properties are public
|
-[x] Item properties are public
|
||||||
-[x] multiple access by index
|
-[x] multiple access by index
|
||||||
|
|
||||||
@ -38,6 +38,6 @@
|
|||||||
-[x] extract methods
|
-[x] extract methods
|
||||||
-[x] extract boolean methods
|
-[x] extract boolean methods
|
||||||
-[x] encapsulate methods
|
-[x] encapsulate methods
|
||||||
-[ ] isolate specific logics
|
-[x] isolate specific logics
|
||||||
-[x] move specific logic to backstage
|
-[x] move specific logic to backstage
|
||||||
-[x] move specific logic of sulfuras
|
-[x] move specific logic of sulfuras
|
||||||
|
|||||||
@ -14,37 +14,37 @@ class GildedRose {
|
|||||||
|
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
|
||||||
final Item item = items[i];
|
final Item item = items[i];
|
||||||
|
|
||||||
item.updateSellIn();
|
item.updateSellIn();
|
||||||
|
|
||||||
if(item.name.equals(Brie.BRIE)){
|
if(item.name.equals(Brie.BRIE)){
|
||||||
updateBrieQuality(item);
|
updateBrieQuality(item);
|
||||||
}else if (item.name.equals(Backstage.BACKSTAGE)){
|
}else if (item.name.equals(Backstage.BACKSTAGE)){
|
||||||
updateBackstageQuality(item);
|
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) {
|
private void updateItemQuality(Item item) {
|
||||||
if (!item.name.equals(Backstage.BACKSTAGE)) {
|
if (!item.name.equals(Backstage.BACKSTAGE)) {
|
||||||
if (!item.name.equals(Sulfuras.SULFURAS) && item.quality > 0) {
|
if (item.quality > 0 ) {
|
||||||
item.decreaseQuality();
|
item.decreaseQuality();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
item.quality = 0;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user