-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[신예진] 1차 과제 제출 #12
base: develop
Are you sure you want to change the base?
[신예진] 1차 과제 제출 #12
Conversation
public class Conjured implements UpdateLogic{ | ||
|
||
@Override | ||
public void update(Item item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저의 품질 감소 로직보다 훨씬 더 가독성 좋고 간결하게 작성하신 거 같습니다!
잘 봤습니다.
import com.gildedrose.Item; | ||
|
||
public class UpdateLogicFactory { | ||
public static UpdateLogic getUpdateLogic(Item item){ | ||
switch (item.name) { | ||
case "Aged Brie": | ||
return new AgedBrie(); | ||
case "Backstage passes to a TAFKAL80ETC concert": | ||
return new BackstagePass(); | ||
case "Sulfuras, Hand of Ragnaros": | ||
return new Sulfuras(); | ||
case "Conjured Mana Cake": | ||
return new Conjured(); | ||
default: | ||
return new DefaultItem(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch - case로 더 명확한 구조를 가지고 있네요!
다만 나중에 제품의 종류가 많아지면 코드가 더 길어질거 같습니다~!
for (Item item : items) { | ||
UpdateLogic updateLogic = updateLogicFactory.getUpdateLogic(item); | ||
updateLogic.update(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 for문을 향상된 for문으로 수정하여 가독성이 좋아진 것 같네요👍
item.quality++; | ||
if (item.sellIn < 11 && item.quality < 50) { | ||
item.quality++; | ||
} | ||
if (item.sellIn < 6 && item.quality < 50) { | ||
item.quality++; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
가독성을 위해 10 이하, 5 이하로 바꿔보는것도 좋을 것 같습니다!
신예진 과제 제출합니다.