123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void updateQuality() {
- for(Item item : items) {
-
- if(item.getName().startsWith("Sulfuras")) {
- continue; // Doesnt have to be sold or decrease in quality
- }
-
- int curQuality = item.getQuality();
- int qualityChange = item.getName().equals("Aged Brie") ? 1 : -1;
- qualityChange *= item.getSellIn() < 1 ? 2 : 1;
- int newQuality = curQuality + qualityChange;
-
- if(newQuality < 0)
- newQuality = 0;
-
- if(newQuality > 50)
- newQuality = 50;
-
- item.setQuality(newQuality);
- item.setSellIn(item.getSellIn() - 1);
- }
- }
- }
-
-
-
-
-
-
- /* public void updateQuality() {
- for (int i = 0; i < items.length; i++) {
- if (!items[i].getName().equals("Aged Brie")) {
- if (items[i].getQuality() > 0) {
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- items[i].setQuality(items[i].getQuality() - 1);
- }
- }
- } else {
- if (items[i].getQuality() < 50) {
- items[i].setQuality(items[i].getQuality() + 1);
- }
- }
-
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- items[i].setSellIn(items[i].getSellIn() - 1);
- }
-
- if (items[i].getSellIn() < 0) {
- if (!items[i].getName().equals("Aged Brie")) {
- items[i].setQuality(items[i].getQuality() - 1);
- } else {
- if (items[i].getQuality() < 50) {
- items[i].setQuality(items[i].getQuality() + 1);
- }
- }
- }
- }
- }
- }*/
|