Explorar el Código

removed level 2 code

Nhu Nguyen hace 6 años
padre
commit
cba90cc423
Se han modificado 2 ficheros con 5 adiciones y 105 borrados
  1. 5
    42
      Inventory.java
  2. 0
    63
      InventoryTest.java

+ 5
- 42
Inventory.java Ver fichero

@@ -7,64 +7,27 @@ public class Inventory {
7 7
         this.items = items;
8 8
     }
9 9
 
10
-    public Inventory() {
11
-        super();
12
-        items = new Item[] {
13
-                    new Item("+5 Dexterity Vest", 10, 20), 
14
-                    new Item("Aged Brie", 2, 0),
15
-                    new Item("Elixir of the Mongoose", 5, 7),
16
-                    new Item("Sulfuras, Hand of Ragnaros", 0, 80),
17
-                    new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
18
-                    new Item("Conjured Mana Cake", 3, 6) 
19
-                };
20
-
21
-    }
22
-
23 10
     public void updateQuality() {
24 11
         for (int i = 0; i < items.length; i++) {
25
-            if (items[i].getName() != "Aged Brie"
26
-                    && items[i].getName() != "Backstage passes to a TAFKAL80ETC concert") {
12
+            if (!items[i].getName().equals("Aged Brie")) {
27 13
                 if (items[i].getQuality() > 0) {
28
-                    if (items[i].getName() != "Sulfuras, Hand of Ragnaros") {
14
+                    if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
29 15
                         items[i].setQuality(items[i].getQuality() - 1);
30 16
                     }
31 17
                 }
32 18
             } else {
33 19
                 if (items[i].getQuality() < 50) {
34 20
                     items[i].setQuality(items[i].getQuality() + 1);
35
-
36
-                    if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
37
-                        if (items[i].getSellIn() < 11) {
38
-                            if (items[i].getQuality() < 50) {
39
-                                items[i].setQuality(items[i].getQuality() + 1);
40
-                            }
41
-                        }
42
-
43
-                        if (items[i].getSellIn() < 6) {
44
-                            if (items[i].getQuality() < 50) {
45
-                                items[i].setQuality(items[i].getQuality() + 1);
46
-                            }
47
-                        }
48
-                    }
49 21
                 }
50 22
             }
51 23
 
52
-            if (items[i].getName() != "Sulfuras, Hand of Ragnaros") {
24
+            if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
53 25
                 items[i].setSellIn(items[i].getSellIn() - 1);
54 26
             }
55 27
 
56 28
             if (items[i].getSellIn() < 0) {
57
-                if (items[i].getName() != "Aged Brie") {
58
-                    if (items[i].getName() != "Backstage passes to a TAFKAL80ETC concert") {
59
-                        if (items[i].getQuality() > 0) {
60
-                            if (items[i].getName() != "Sulfuras, Hand of Ragnaros") {
61
-                                items[i].setQuality(items[i].getQuality() - 1);
62
-                            }
63
-                        }
64
-                    } else {
65
-                        items[i].setQuality(items[i].getQuality()
66
-                                - items[i].getQuality());
67
-                    }
29
+                if (!items[i].getName().equals("Aged Brie")) {
30
+                  items[i].setQuality(items[i].getQuality() - 1);
68 31
                 } else {
69 32
                     if (items[i].getQuality() < 50) {
70 33
                         items[i].setQuality(items[i].getQuality() + 1);

+ 0
- 63
InventoryTest.java Ver fichero

@@ -107,67 +107,4 @@ public class InventoryTest {
107 107
 
108 108
         assertEquals(MAX_QUALITY, agedBrie.getQuality());
109 109
     }
110
-
111
-    @Test
112
-    public void testUpdate_ForBackstagePassesAfterTheConcertOccurred() throws Exception {
113
-        Item backStagePass = new Item(BACKSTAGE_PASS_NAME, -1, 20);
114
-        Item[] items = {backStagePass};
115
-        Inventory sut = new Inventory(items);
116
-
117
-        sut.updateQuality();
118
-
119
-        assertEquals(0, backStagePass.getQuality());
120
-    }
121
-
122
-    @Test
123
-    public void testUpdate_ForBackstagePassesQualityWhenTheConcertIsMoreThan10DaysAway() throws Exception {
124
-        Item backStagePass = new Item(BACKSTAGE_PASS_NAME, 11, 20);
125
-        int expectedQuality = backStagePass.getQuality() + 1;
126
-        Item[] items = {backStagePass};
127
-        Inventory sut = new Inventory(items);
128
-
129
-        sut.updateQuality();
130
-
131
-        assertEquals(21, backStagePass.getQuality());
132
-    }
133
-
134
-    @Test
135
-    public void testUpdate_ForBackstagePassesWhenTheConcertIs10DaysOrLessAway() throws Exception {
136
-        Item backStagePass = new Item(BACKSTAGE_PASS_NAME, 10, 27);
137
-        int expectedQuality = backStagePass.getQuality() + 2;
138
-        Item[] items = {backStagePass};
139
-        Inventory sut = new Inventory(items);
140
-
141
-        sut.updateQuality();
142
-
143
-        assertEquals(expectedQuality, backStagePass.getQuality());
144
-    }
145
-
146
-    @Test
147
-    public void testUpdate_ForBackstagePassesWhenTheConcertIs5DaysOrLessAway() throws Exception {
148
-        Item backStagePass = new Item(BACKSTAGE_PASS_NAME, 5, 44);
149
-        int expectedQuality = backStagePass.getQuality() + 3;
150
-        Item[] items = {backStagePass};
151
-        Inventory sut = new Inventory(items);
152
-
153
-        sut.updateQuality();
154
-
155
-        assertEquals(expectedQuality, backStagePass.getQuality());
156
-    }
157
-
158
-    @Test
159
-    public void testUpdate_WhenBackstagePassesIsAtOrNeaerMaxQuality() throws Exception {
160
-        Item backStagePassMoreThan10DaysAway = new Item(BACKSTAGE_PASS_NAME, 15, MAX_QUALITY);
161
-        Item backStagePass10DaysAway = new Item(BACKSTAGE_PASS_NAME, 10, MAX_QUALITY - 1);
162
-        Item backStagePass5DaysAway = new Item(BACKSTAGE_PASS_NAME, 5, MAX_QUALITY - 2);
163
-
164
-        Item[] items = {backStagePassMoreThan10DaysAway, backStagePass10DaysAway, backStagePass5DaysAway};
165
-        Inventory sut = new Inventory(items);
166
-
167
-        sut.updateQuality();
168
-
169
-        assertEquals(MAX_QUALITY, backStagePassMoreThan10DaysAway.getQuality());
170
-        assertEquals(MAX_QUALITY, backStagePass10DaysAway.getQuality());
171
-        assertEquals(MAX_QUALITY, backStagePass5DaysAway.getQuality());
172
-    }
173 110
 }