mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
Add javadocs
This commit is contained in:
parent
e97cf12d15
commit
1905a68b56
@ -1,6 +1,9 @@
|
||||
package com.gildedrose;
|
||||
|
||||
public class AgedBrie extends RegularItem {
|
||||
/**
|
||||
* Class for Aged Brie item inherited from NormalItem
|
||||
*/
|
||||
public class AgedBrie extends NormalItem {
|
||||
|
||||
public AgedBrie(Item item) {
|
||||
this.item=item;
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
package com.gildedrose;
|
||||
|
||||
public class BackStageItem extends RegularItem{
|
||||
/**
|
||||
* Class Back Stage item inherited form NormalItem
|
||||
*
|
||||
* Business rules are inherited from NormalItem with more conditions:
|
||||
* Quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less
|
||||
*/
|
||||
public class BackStageItem extends NormalItem {
|
||||
public BackStageItem(Item item) {
|
||||
this.item=item;
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.gildedrose;
|
||||
|
||||
public class ConjuredItem extends RegularItem {
|
||||
/**
|
||||
* Class for the item ConjuredItem inherited from NormalItem
|
||||
*/
|
||||
public class ConjuredItem extends NormalItem {
|
||||
public ConjuredItem(Item item) {
|
||||
this.item=item;
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.gildedrose;
|
||||
|
||||
/**
|
||||
* Class which update quality for all items
|
||||
*/
|
||||
class GildedRoseItem {
|
||||
Item[] items;
|
||||
public static final String SULFURA = "Sulfuras, Hand of Ragnaros";
|
||||
@ -27,8 +30,8 @@ class GildedRoseItem {
|
||||
ConjuredItem conjuredItem = new ConjuredItem(item);
|
||||
conjuredItem.updateQuality();
|
||||
} else {
|
||||
RegularItem regularItem = new RegularItem(item);
|
||||
regularItem.updateQuality();
|
||||
NormalItem normalItem = new NormalItem(item);
|
||||
normalItem.updateQuality();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,20 @@
|
||||
package com.gildedrose;
|
||||
|
||||
public class RegularItem {
|
||||
/**
|
||||
* Class for a regular item with business rule for normal item:
|
||||
* If the item expired => reduce the quality by 2 else reduce by 1
|
||||
* Quality for an item is never negative
|
||||
* Quality for an item is not greater than the constant MAX_QUAILITY_FOR_AN_ITEM
|
||||
*/
|
||||
public class NormalItem {
|
||||
public static final int MAX_QUAILITY_FOR_AN_ITEM = 50;
|
||||
public Item item;
|
||||
|
||||
public RegularItem() {
|
||||
public NormalItem() {
|
||||
|
||||
}
|
||||
|
||||
public RegularItem(Item item) {
|
||||
public NormalItem(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@ -31,7 +38,7 @@ public class RegularItem {
|
||||
|
||||
protected void increaseQualityBy(int factor) {
|
||||
item.quality += factor;
|
||||
qualityOfAnItemIsNotMoreThan(50);
|
||||
qualityOfAnItemIsNotMoreThan(MAX_QUAILITY_FOR_AN_ITEM);
|
||||
}
|
||||
|
||||
protected void decreaseQualityBy(int factor) {
|
||||
@ -5,6 +5,9 @@ import java.util.HashMap;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test the result of item.sellIn and item.quality after n days
|
||||
*/
|
||||
public class GildedRoseItemTest {
|
||||
private Item[] itemsSample = new Item[]{new Item("+5 Dexterity Vest", 10, 20), //
|
||||
new Item("Aged Brie", 2, 0), //
|
||||
|
||||
Loading…
Reference in New Issue
Block a user