Skip to content

Commit

Permalink
코드 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeonkyujin committed Oct 30, 2024
1 parent 47026ac commit 6801a39
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
7 changes: 2 additions & 5 deletions Java/src/main/java/com/gildedrose/AgedBrieItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ public AgedBrieItem(Item item) {
@Override
public void updateQuality() {
increaseQuality(item);

//나머지 일수가 없어지면 2배로 증가
if (item.sellIn < 0) {
increaseQuality(item);
}

fixQuality(item);
decreaseSellIn(item);
}

}




5 changes: 4 additions & 1 deletion Java/src/main/java/com/gildedrose/BackStageItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ public BackStageItem(Item item) {
public void updateQuality() {
//남은 일자가 11일이상이면 1 증가
increaseQuality(item);

//남은 일자가 6~10일이면 2 증가
if (item.sellIn <= 10) {
increaseQuality(item);
}

//남은 일자가 5일이하면 3증가
if (item.sellIn <= 5) {
increaseQuality(item);
}

//남은 일자가 없으면 0
if (item.sellIn == 0) {
item.quality = 0;
}

fixQuality(item);
decreaseSellIn(item);
}
}

2 changes: 2 additions & 0 deletions Java/src/main/java/com/gildedrose/CommonItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ public CommonItem(Item item) {
@Override
public void updateQuality() {
decreaseQuality(item);

//나머지 일수가 없어지면 2배로 감소
if (item.sellIn < 0) {
decreaseQuality(item);
}

fixQuality(item);
decreaseSellIn(item);
}
Expand Down
3 changes: 2 additions & 1 deletion Java/src/main/java/com/gildedrose/ConjuredItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ public ConjuredItem(Item item) {
@Override
public void updateQuality() {
doubleDecreaseQuality(item);

//나머지 일수가 없어지면 2배로 감소
if (item.sellIn < 0) {
doubleDecreaseQuality(item);
}

fixQuality(item);
decreaseSellIn(item);
}
}

5 changes: 1 addition & 4 deletions Java/src/main/java/com/gildedrose/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class GildedRose {
public GildedRose(Item[] items) {
this.items = items;
this.updatingItems = new UpdateItem[items.length];

for (int i = 0; i < items.length; i++) {
if (items[i].name.equals("Aged Brie")) {
updatingItems[i] = new AgedBrieItem(items[i]);
Expand All @@ -29,10 +30,6 @@ public void updateQuality() {
//item에 따라 적절한 구현클래스 로직 실행
for (UpdateItem item : updatingItems) {
item.updateQuality();

}
}

}


1 change: 0 additions & 1 deletion Java/src/main/java/com/gildedrose/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ public String toString() {
return this.name + ", " + this.sellIn + ", " + this.quality;
}
}

1 change: 0 additions & 1 deletion Java/src/main/java/com/gildedrose/SulfurasItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ public SulfurasItem(Item item) {
public void updateQuality() {
}
}

1 change: 1 addition & 0 deletions Java/src/main/java/com/gildedrose/UpdateItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected void fixQuality(Item item) {
if (item.quality > 50) {
item.quality = 50;
}

if (item.quality < 0) {
item.quality = 0;
}
Expand Down

0 comments on commit 6801a39

Please sign in to comment.