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
|
||||
-[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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user