package com.gildedrose;

class GildedRose {
  private static final String SULFURAS_HAND_OF_RAGNAROS = "Sulfuras, Hand of Ragnaros";
  Item[] items;

  public GildedRose(Item[] items) {
    this.items = items;
    for (Item item : items) {
      item.quality = (item.quality < 0) ? 0 : item.quality;
    }
  }

  public void updateQuality() {
    for (Item item : items) {
      if (!item.name.equals("Aged Brie") && !item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
        if (item.quality > 0) {
          if (!item.name.equals(SULFURAS_HAND_OF_RAGNAROS)) {
            item.quality = item.quality - 1;
          }
        }
      } else {
        if (item.quality < 50) {
          item.quality = item.quality + 1;

          if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
            if (item.sellIn < 11) {
              if (item.quality < 50) {
                item.quality = item.quality + 1;
              }
            }

            if (item.sellIn < 6) {
              if (item.quality < 50) {
                item.quality = item.quality + 1;
              }
            }
          }
        }
      }

      if (!item.name.equals(SULFURAS_HAND_OF_RAGNAROS)) {
        item.sellIn = item.sellIn - 1;
      }

      if (item.sellIn < 0) {
        if (!item.name.equals("Aged Brie")) {
          if (!item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
            if (item.quality > 0) {
              if (!item.name.equals(SULFURAS_HAND_OF_RAGNAROS)) {
                item.quality = item.quality - 1;
              }
            }
          } else {
            item.quality = item.quality - item.quality;
          }
        } else {
          if (item.quality < 50) {
            item.quality = item.quality + 1;
          }
        }
      }
    }
  }
}

@@ -40,16 +40,136 @@
 Rose %7B%0D%0A
+  private static final String BACKSTAGE_PASSES_TO_A_TAFKAL80ETC_CONCERT = %22Backstage passes to a TAFKAL80ETC concert%22;%0D%0A
   privat
@@ -249,16 +249,16 @@
 aros%22;%0D%0A
-
   Item%5B%5D
@@ -562,39 +562,38 @@
 .equals(
-%22Backstage passes to a 
+BACKSTAGE_PASSES_TO_A_
 TAFKAL80
@@ -591,33 +591,32 @@
 _TAFKAL80ETC
- concert%22
+_CONCERT
 )) %7B%0D%0A      
@@ -902,39 +902,38 @@
 .equals(
-%22Backstage passes to a 
+BACKSTAGE_PASSES_TO_A_
 TAFKAL80
@@ -931,33 +931,32 @@
 _TAFKAL80ETC
- concert%22
+_CONCERT
 )) %7B%0D%0A      
@@ -1522,39 +1522,38 @@
 .equals(
-%22Backstage passes to a 
+BACKSTAGE_PASSES_TO_A_
 TAFKAL80
@@ -1555,25 +1555,24 @@
 KAL80ETC
- concert%22
+_CONCERT
 )) %7B%0D%0A  

constant for concert