mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
Added comments
This commit is contained in:
parent
9d878b7641
commit
d11808fa8f
@ -8,7 +8,11 @@ class GildedRose {
|
||||
}
|
||||
|
||||
public void updateQuality() {
|
||||
|
||||
// Horrible loop for iterating through items array
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
|
||||
// ----- Block 1 ----- Reduce quality of item by 1 for a day if not AB, BptaTc or SHoR
|
||||
if (!items[i].name.equals("Aged Brie")
|
||||
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (items[i].quality > 0) {
|
||||
@ -16,10 +20,13 @@ class GildedRose {
|
||||
items[i].quality = items[i].quality - 1;
|
||||
}
|
||||
}
|
||||
// If Aged Brie or BptaTc
|
||||
} else {
|
||||
// Increase quality of item by + 1
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
|
||||
// If pass has less than 11 days to sell, quality increases by + 1
|
||||
if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (items[i].sellIn < 11) {
|
||||
if (items[i].quality < 50) {
|
||||
@ -27,6 +34,7 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
// If pass has 6 days to sell, quality increases by + 2
|
||||
if (items[i].sellIn < 6) {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
@ -36,11 +44,15 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Block 2 ------ Item reduces by a day - 1 (unless SHoR)
|
||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
items[i].sellIn = items[i].sellIn - 1;
|
||||
}
|
||||
|
||||
// ----- Block 3 ----- Item sell date is less than 0
|
||||
if (items[i].sellIn < 0) {
|
||||
|
||||
// Reduce quality of items by - 1 if greater than 0 and not AB, BptaTc or SHoR
|
||||
if (!items[i].name.equals("Aged Brie")) {
|
||||
if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (items[i].quality > 0) {
|
||||
@ -49,8 +61,11 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Item quality goes to 0 of BptaTc as item sell date is less than 0
|
||||
items[i].quality = items[i].quality - items[i].quality;
|
||||
}
|
||||
|
||||
// Increase quality of item if AB
|
||||
} else {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user