mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 20:32:15 +00:00
In Java it's best practice to use .equals for strings. Even though this is supposed to be legacy code, the use of == led to some hard to understand errors that distract from the exercise.
This commit is contained in:
parent
2e7e36eda1
commit
1fcd221677
@ -7,10 +7,10 @@ class GildedRose {
|
|||||||
|
|
||||||
public void updateQuality() {
|
public void updateQuality() {
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
if (items[i].name != "Aged Brie"
|
if (!items[i].name.equals("Aged Brie")
|
||||||
&& items[i].name != "Backstage passes to a TAFKAL80ETC concert") {
|
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (items[i].quality > 0) {
|
if (items[i].quality > 0) {
|
||||||
if (items[i].name != "Sulfuras, Hand of Ragnaros") {
|
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||||
items[i].quality = items[i].quality - 1;
|
items[i].quality = items[i].quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ class GildedRose {
|
|||||||
if (items[i].quality < 50) {
|
if (items[i].quality < 50) {
|
||||||
items[i].quality = items[i].quality + 1;
|
items[i].quality = items[i].quality + 1;
|
||||||
|
|
||||||
if (items[i].name == "Backstage passes to a TAFKAL80ETC concert") {
|
if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (items[i].sellIn < 11) {
|
if (items[i].sellIn < 11) {
|
||||||
if (items[i].quality < 50) {
|
if (items[i].quality < 50) {
|
||||||
items[i].quality = items[i].quality + 1;
|
items[i].quality = items[i].quality + 1;
|
||||||
@ -34,15 +34,15 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items[i].name != "Sulfuras, Hand of Ragnaros") {
|
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||||
items[i].sellIn = items[i].sellIn - 1;
|
items[i].sellIn = items[i].sellIn - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items[i].sellIn < 0) {
|
if (items[i].sellIn < 0) {
|
||||||
if (items[i].name != "Aged Brie") {
|
if (!items[i].name.equals("Aged Brie")) {
|
||||||
if (items[i].name != "Backstage passes to a TAFKAL80ETC concert") {
|
if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (items[i].quality > 0) {
|
if (items[i].quality > 0) {
|
||||||
if (items[i].name != "Sulfuras, Hand of Ragnaros") {
|
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||||
items[i].quality = items[i].quality - 1;
|
items[i].quality = items[i].quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,5 +57,4 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user