Soujanya Buragapu 6 лет назад
Родитель
Сommit
7ed8439e72

+ 49
- 30
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Просмотреть файл

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

+ 16
- 8
src/main/java/com/zipcodewilmington/gildedrose/Item.java Просмотреть файл

@@ -1,38 +1,46 @@
1 1
 package com.zipcodewilmington.gildedrose;
2 2
 
3
-public class Item {
3
+public class Item
4
+{
4 5
     private String name;
5 6
     private int sellIn;
6 7
     private int quality;
7 8
 
8
-    public Item(String name, int sellIn, int quality) {
9
+    public Item(String name, int sellIn, int quality)
10
+    {
9 11
         super();
10 12
         this.name = name;
11 13
         this.sellIn = sellIn;
12 14
         this.quality = quality;
13 15
     }
14 16
 
15
-    public String getName() {
17
+    public String getName()
18
+    {
16 19
         return name;
17 20
     }
18 21
 
19
-    public void setName(String name) {
22
+    public void setName(String name)
23
+    {
20 24
         this.name = name;
21 25
     }
22 26
 
23
-    public int getSellIn() {
27
+    public int getSellIn()
28
+    {
24 29
         return sellIn;
25 30
     }
26 31
 
27
-    public void setSellIn(int sellIn) {
32
+    public void setSellIn(int sellIn)
33
+    {
28 34
         this.sellIn = sellIn;
29 35
     }
30 36
 
31
-    public int getQuality() {
37
+    public int getQuality()
38
+    {
32 39
         return quality;
33 40
     }
34 41
 
35
-    public void setQuality(int quality) {
42
+    public void setQuality(int quality)
43
+    {
36 44
         this.quality = quality;
37 45
     }
38 46
 }

+ 4
- 2
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java Просмотреть файл

@@ -3,9 +3,11 @@ package com.zipcodewilmington.gildedrose;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 
6
-public class InventoryTest {
6
+public class InventoryTest
7
+{
7 8
     @Test
8
-    public void updateQuantityTest(){
9
+    public void updateQuantityTest()
10
+    {
9 11
         Assert.assertEquals(1, 1);
10 12
     }
11 13
 }