mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
extract hardcoded variables
This commit is contained in:
parent
8157a26c4b
commit
5369c431b5
@ -22,7 +22,11 @@
|
||||
-[x] however "Sulfuras" is a legendary item and as such its Quality is 80 and it never alters.
|
||||
|
||||
## Technical Issues, with a balanced priority
|
||||
-[ ]
|
||||
-[x] item names are hardcoded
|
||||
-[ ] items are identified by the name in a hardcoded way
|
||||
-[ ] nested logic
|
||||
-[ ] Item properties are public
|
||||
|
||||
## Refactoring actions
|
||||
-[x] extract hardcoded variables
|
||||
|
||||
|
||||
@ -3,16 +3,21 @@ package com.gildedrose;
|
||||
class GildedRose {
|
||||
Item[] items;
|
||||
|
||||
String BRIE = "Aged Brie";
|
||||
String BACKSTAGE = "Backstage passes to a TAFKAL80ETC concert";
|
||||
|
||||
String SULFURAS = "Sulfuras, Hand of Ragnaros";
|
||||
|
||||
public GildedRose(Item[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void updateQuality() {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (!items[i].name.equals("Aged Brie")
|
||||
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (!items[i].name.equals(BRIE)
|
||||
&& !items[i].name.equals(BACKSTAGE)) {
|
||||
if (items[i].quality > 0) {
|
||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
if (!items[i].name.equals(SULFURAS)) {
|
||||
items[i].quality = items[i].quality - 1;
|
||||
}
|
||||
}
|
||||
@ -20,7 +25,7 @@ class GildedRose {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
|
||||
if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (items[i].name.equals(BACKSTAGE)) {
|
||||
if (items[i].sellIn < 11) {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
@ -36,15 +41,15 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
if (!items[i].name.equals(SULFURAS)) {
|
||||
items[i].sellIn = items[i].sellIn - 1;
|
||||
}
|
||||
|
||||
if (items[i].sellIn < 0) {
|
||||
if (!items[i].name.equals("Aged Brie")) {
|
||||
if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (!items[i].name.equals(BRIE)) {
|
||||
if (!items[i].name.equals(BACKSTAGE)) {
|
||||
if (items[i].quality > 0) {
|
||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
if (!items[i].name.equals(SULFURAS)) {
|
||||
items[i].quality = items[i].quality - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user