Eric Foster 6 年之前
父節點
當前提交
d5ff54553f
共有 2 個文件被更改,包括 39 次插入18 次删除
  1. 32
    11
      Inventory.java
  2. 7
    7
      package.bluej

+ 32
- 11
Inventory.java 查看文件

@@ -7,28 +7,35 @@ public class Inventory {
7 7
         this.items = items;
8 8
     }
9 9
 
10
-
11 10
     public void updateQuality() {
12 11
         for (int i = 0; i < items.length; i++) {
12
+            //level 1 - item type
13 13
             if (!items[i].getName().equals("Aged Brie")
14
-                    && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
14
+            && !items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
15
+                //level 2 - quality
15 16
                 if (items[i].getQuality() > 0) {
17
+                    //level 3 - item type
16 18
                     if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
17 19
                         items[i].setQuality(items[i].getQuality() - 1);
18 20
                     }
19 21
                 }
22
+            //level 1 - item type
20 23
             } else {
24
+                //level 2 - quality
21 25
                 if (items[i].getQuality() < 50) {
22 26
                     items[i].setQuality(items[i].getQuality() + 1);
23
-
27
+                    //level 3 - item type
24 28
                     if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
29
+                        //level 4 - sell in date
25 30
                         if (items[i].getSellIn() < 11) {
31
+                            //level 5 - quality
26 32
                             if (items[i].getQuality() < 50) {
27 33
                                 items[i].setQuality(items[i].getQuality() + 1);
28 34
                             }
29 35
                         }
30
-
36
+                        //level 4 - sell in date
31 37
                         if (items[i].getSellIn() < 6) {
38
+                            //level 5 - quality
32 39
                             if (items[i].getQuality() < 50) {
33 40
                                 items[i].setQuality(items[i].getQuality() + 1);
34 41
                             }
@@ -36,29 +43,43 @@ public class Inventory {
36 43
                     }
37 44
                 }
38 45
             }
39
-
46
+            
47
+            
48
+            //level 1 - item type
40 49
             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
41 50
                 items[i].setSellIn(items[i].getSellIn() - 1);
42 51
             }
43
-
52
+            
53
+            
54
+            //level 1 - sell in date
44 55
             if (items[i].getSellIn() < 0) {
56
+                //level 2 - item type
45 57
                 if (!items[i].getName().equals("Aged Brie")) {
58
+                    //level 3 - item type
46 59
                     if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
60
+                        //level 4 - quality
47 61
                         if (items[i].getQuality() > 0) {
62
+                            //level 5 - item type
48 63
                             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
49
-                                items[i].setQuality(items[i].getQuality() - 1);
64
+                                updateQuality(items[i], -1);
50 65
                             }
51 66
                         }
67
+                    //level 3 - item type
52 68
                     } else {
53
-                        items[i].setQuality(items[i].getQuality()
54
-                                - items[i].getQuality());
69
+                        updateQuality(items[i], -items[i].getQuality());
55 70
                     }
71
+                //level 2 - item type
56 72
                 } else {
73
+                    //level 3 - quality
57 74
                     if (items[i].getQuality() < 50) {
58
-                        items[i].setQuality(items[i].getQuality() + 1);
75
+                        updateQuality(items[i], 1);
59 76
                     }
60 77
                 }
61 78
             }
62 79
         }
63
-}
80
+    }
81
+    
82
+    public void updateQuality(Item item, int amount){
83
+        item.setQuality(item.getQuality() + amount);
84
+    }
64 85
 }

+ 7
- 7
package.bluej 查看文件

@@ -5,18 +5,18 @@ dependency1.type=UsesDependency
5 5
 dependency2.from=InventoryTest
6 6
 dependency2.to=Inventory
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=722
9
-editor.fx.0.width=800
10
-editor.fx.0.x=320
11
-editor.fx.0.y=50
8
+editor.fx.0.height=1054
9
+editor.fx.0.width=1033
10
+editor.fx.0.x=-318
11
+editor.fx.0.y=-1057
12 12
 objectbench.height=164
13
-objectbench.width=776
13
+objectbench.width=461
14 14
 package.divider.horizontal=0.6
15 15
 package.divider.vertical=0.6845018450184502
16 16
 package.editor.height=364
17 17
 package.editor.width=674
18
-package.editor.x=577
19
-package.editor.y=61
18
+package.editor.x=779
19
+package.editor.y=-991
20 20
 package.frame.height=600
21 21
 package.frame.width=800
22 22
 package.numDependencies=2