1234567891011121314151617181920212223242526272829303132333435363738394041 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void updateQuality() {
- for (int i = 0; i < items.length; i++) {
- if (items[i].getName().equalsIgnoreCase("Aged Brie")) {
- getCheeseQuality(items[i]);
- } else if (items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- } else {
- getItemQuality(items[i]);
- } if(items[i].getQuality() < 80){
- items[i].setSellIn(items[i].getSellIn() -1);
- }
- }
- }
-
- public void getCheeseQuality(Item item) {
- if (item.getQuality() < 50 && item.getSellIn() > 0) {
- item.setQuality(item.getQuality() + 1);
- } else if (item.getSellIn() < 0 && item.getQuality() < 50) {
- item.setQuality(item.getQuality() + 2);
- }
- }
-
- public void getItemQuality(Item item) {
- if(item.getQuality() > 0 && item.getSellIn() > 0) {
- item.setQuality(item.getQuality() - 1);
- } else if(item.getSellIn() < 0) {
- item.setQuality(item.getQuality()-2);
- }
- }
-
- }
-
|