瀏覽代碼

interim update

donnaj 6 年之前
父節點
當前提交
189a4d567c
共有 3 個檔案被更改,包括 50 行新增26 行删除
  1. 44
    20
      Inventory.java
  2. 0
    0
      README.TXT
  3. 6
    6
      package.bluej

+ 44
- 20
Inventory.java 查看文件

@@ -10,30 +10,54 @@ public class Inventory {
10 10
     public void updateQuality() {
11 11
         for (int i = 0; i < items.length; i++) {
12 12
             if (!items[i].getName().equals("Aged Brie")) {
13
-                if (items[i].getQuality() > 0) {
14
-                    if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
15
-                        items[i].setQuality(items[i].getQuality() - 1);
16
-                    }
17
-                }
18
-            } else {
19
-                if (items[i].getQuality() < 50) {
20
-                    items[i].setQuality(items[i].getQuality() + 1);
21
-                }
13
+                regItemUpdate();
14
+                // if (items[i].getQuality() > 0) {
15
+                    // if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
16
+                        // items[i].setQuality(items[i].getQuality() - 1);
17
+                    // }
18
+                // }
19
+            } else {agedBrieUpdate();
20
+                // if (items[i].getQuality() < 50) {
21
+                    // items[i].setQuality(items[i].getQuality() + 1);
22
+                // }
22 23
             }
24
+            
23 25
 
24 26
             if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
25
-                items[i].setSellIn(items[i].getSellIn() - 1);
27
+                // items[i].setSellIn(items[i].getSellIn() - 1);
28
+                continue;
26 29
             }
27 30
 
28
-            if (items[i].getSellIn() < 0) {
29
-                if (!items[i].getName().equals("Aged Brie")) {
30
-                  items[i].setQuality(items[i].getQuality() - 1);
31
-                } else {
32
-                    if (items[i].getQuality() < 50) {
33
-                        items[i].setQuality(items[i].getQuality() + 1);
34
-                    }
35
-                }
36
-            }
31
+            // if (items[i].getSellIn() < 0) {
32
+                // if (!items[i].getName().equals("Aged Brie")) {
33
+                  // items[i].setQuality(items[i].getQuality() - 1);
34
+                // } else {
35
+                    // if (items[i].getQuality() < 50) {
36
+                        // items[i].setQuality(items[i].getQuality() + 1);
37
+                    // }
38
+                // }
39
+            // }
37 40
         }
38
-}
41
+    }
42
+
43
+    public void agedBrieUpdate() {
44
+        int i = 0;
45
+        if (items[i].getSellIn() > 0 && items[i].getQuality() <=49) {
46
+	items[i].setQuality(items[i].getQuality() + 1);
47
+	} else if (items[i].getSellIn() < 0 && items[i].getQuality() <= 48){
48
+	    items[i].setQuality(items[i].getQuality() + 2);	
49
+	   }
50
+
51
+    }
52
+    
53
+    public void regItemUpdate() {
54
+        int i = 0;
55
+        if (items[i].getSellIn() > 0) {
56
+	items[i].setQuality(items[i].getQuality() - 1);
57
+	} else if (items[i].getSellIn() < 0){
58
+	    items[i].setQuality(items[i].getQuality() - 2);	
59
+	   }
60
+
61
+    }
62
+
39 63
 }

+ 0
- 0
README.TXT 查看文件


+ 6
- 6
package.bluej 查看文件

@@ -5,17 +5,17 @@ dependency1.type=UsesDependency
5 5
 dependency2.from=InventoryTest
6 6
 dependency2.to=Inventory
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=722
8
+editor.fx.0.height=712
9 9
 editor.fx.0.width=800
10 10
 editor.fx.0.x=320
11
-editor.fx.0.y=50
11
+editor.fx.0.y=23
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
18
+package.editor.x=480
19 19
 package.editor.y=61
20 20
 package.frame.height=600
21 21
 package.frame.width=800
@@ -34,8 +34,8 @@ target1.name=Item
34 34
 target1.showInterface=false
35 35
 target1.type=ClassTarget
36 36
 target1.width=80
37
-target1.x=10
38
-target1.y=100
37
+target1.x=30
38
+target1.y=90
39 39
 target2.height=50
40 40
 target2.name=InventoryTest
41 41
 target2.showInterface=false