Inventory.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. public class Inventory {
  2. private Item[] items;
  3. public Inventory(Item[] items) {
  4. super();
  5. this.items = items;
  6. }
  7. public void updateQuality() {
  8. for (int i = 0; i < items.length; i++) {
  9. if (!items[i].getName().equals("Aged Brie")
  10. && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
  11. if (items[i].getQuality() > 0) {
  12. if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
  13. items[i].setQuality(items[i].getQuality() - 1);
  14. }
  15. }
  16. } else {
  17. if (items[i].getQuality() < 50) {
  18. items[i].setQuality(items[i].getQuality() + 1);
  19. if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
  20. if (items[i].getSellIn() < 11) {
  21. if (items[i].getQuality() < 50) {
  22. items[i].setQuality(items[i].getQuality() + 1);
  23. }
  24. }
  25. if (items[i].getSellIn() < 6) {
  26. if (items[i].getQuality() < 50) {
  27. items[i].setQuality(items[i].getQuality() + 1);
  28. }
  29. }
  30. }
  31. }
  32. }
  33. if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
  34. items[i].setSellIn(items[i].getSellIn() - 1);
  35. }
  36. if (items[i].getSellIn() < 0) {
  37. if (!items[i].getName().equals("Aged Brie")) {
  38. if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
  39. if (items[i].getQuality() > 0) {
  40. if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
  41. items[i].setQuality(items[i].getQuality() - 1);
  42. }
  43. }
  44. } else {
  45. items[i].setQuality(items[i].getQuality()
  46. - items[i].getQuality());
  47. }
  48. } else {
  49. if (items[i].getQuality() < 50) {
  50. items[i].setQuality(items[i].getQuality() + 1);
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }