Procházet zdrojové kódy

added another test and update read me

Nhu Nguyen před 6 roky
rodič
revize
0ce258e53d
2 změnil soubory, kde provedl 82 přidání a 12 odebrání
  1. 12
    0
      InventoryTest.java
  2. 70
    12
      README.MD

+ 12
- 0
InventoryTest.java Zobrazit soubor

107
 
107
 
108
         assertEquals(MAX_QUALITY, agedBrie.getQuality());
108
         assertEquals(MAX_QUALITY, agedBrie.getQuality());
109
     }
109
     }
110
+
111
+    @Test
112
+    public void testUpdate_WhenAgedBrieOnceTheSellInDatePassed() throws Exception {
113
+        Item agedBrie = new Item(AGED_BRIE_NAME, -1, 20);
114
+        int expectedQuality = agedBrie.getQuality() + 2;
115
+        Item[] items = {agedBrie};
116
+        Inventory sut = new Inventory(items);
117
+
118
+        sut.updateQuality();
119
+
120
+        assertEquals(expectedQuality, agedBrie.getQuality());
121
+    }
110
 }
122
 }

+ 70
- 12
README.MD Zobrazit soubor

1
-------------------------------------------------------------------------
2
-This is the project README file. Here, you should describe your project.
3
-Tell the reader (someone who does not know anything about this project)
4
-all he/she needs to know. The comments should usually include at least:
5
-------------------------------------------------------------------------
6
-
7
-PROJECT TITLE:
8
-PURPOSE OF PROJECT:
9
-VERSION or DATE:
10
-HOW TO START THIS PROJECT:
11
-AUTHORS:
12
-USER INSTRUCTIONS:
1
+# Clean Code
2
+
3
+### **Objective:**
4
+* Refactor (aka clean up) the code in the `Inventory` class to make it more maintainable and readable.
5
+
6
+### **Purpose:**
7
+* To understand why writing test matter
8
+* To understand why writing readable code matter
9
+
10
+### **Instructions:**
11
+
12
+1. Fork this Repository
13
+    * [fork](https://help.github.com/articles/fork-a-repo/) this repository to your personal github account
14
+    * [clone](https://help.github.com/articles/cloning-a-repository/) **your** `forked` repository to your local machine.
15
+    * clean up the code in the `Inventory` class
16
+    * commit your changes
17
+    * submit a `pull request` which compares Zipcoder `master` to your `master`.
18
+3. DO NOT CHANGE THE TEST OR THE ITEM CLASS
19
+
20
+# Part 1 - Original Description of the Gilded Rose
21
+
22
+Hi and welcome to team Gilded Rose. As you know, we are a small inn
23
+with a prime location in a prominent city run by a friendly innkeeper
24
+named Allison. We also buy and sell only the finest
25
+goods. Unfortunately, our goods are constantly degrading in quality as
26
+they approach their sell by date. We have a system in place that
27
+updates our inventory for us. It was developed by a no-nonsense type
28
+named Leeroy, who has moved on to new adventures. Your task is to add
29
+the new feature to our system so that we can begin selling a new
30
+category of items. First an introduction to our system:
31
+
32
+- All items have a SellIn value which denotes the number of days we
33
+  have to sell the item
34
+- All items have a Quality value which denotes how valuable the item
35
+  is
36
+- At the end of each day our system lowers both values for every item
37
+
38
+Pretty simple, right? Well this is where it gets interesting:
39
+
40
+  - Once the sell by date has passed, Quality degrades twice as fast
41
+  - The Quality of an item is never negative
42
+  - "Aged Brie" actually increases in Quality the older it gets
43
+  - The Quality of an item is never more than 50
44
+  - "Sulfuras", being a legendary item, never has to be sold or
45
+    decreases in Quality
46
+
47
+Just for clarification, an item can never have its Quality increase
48
+above 50, however "Sulfuras" is a legendary item and as such its
49
+Quality is 80 and it never alters.
50
+
51
+DO NOT alter the Item class or Items property as those belong to the goblin
52
+in the corner who will insta-rage and one-shot you as he doesn't
53
+believe in shared code ownership (you can make the UpdateQuality
54
+method and Items property static if you like, we'll cover for
55
+you).
56
+
57
+## Part 2 - Add a new item
58
+
59
+We have recently signed a supplier of conjured items. This requires an update to our system:
60
+
61
+- "Conjured" items degrade in Quality twice as fast as normal items
62
+
63
+Feel free to make any changes to the UpdateQuality method and add any
64
+new code as long as everything still works correctly.
65
+
66
+## Rules
67
+* No more than two nested if statement in a method
68
+* Don't use the `!` for your if statement
69
+
70
+This was "borrowed" from [alexaitken](https://github.com/alexaitken/GildedRose_java) which originated from [Bobby Johnson's Blog](https://iamnotmyself.com/2011/02/13/refactor-this-the-gilded-rose-kata/).