Skip to content
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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

shinyj0
Copy link
Member

@shinyj0 shinyj0 commented Oct 3, 2024

신예진 과제 제출합니다.

  • 로직분리
  • conjured추가

public class Conjured implements UpdateLogic{

@Override
public void update(Item item) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저의 품질 감소 로직보다 훨씬 더 가독성 좋고 간결하게 작성하신 거 같습니다!
잘 봤습니다.

Comment on lines +3 to +20
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();
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch - case로 더 명확한 구조를 가지고 있네요!
다만 나중에 제품의 종류가 많아지면 코드가 더 길어질거 같습니다~!

Comment on lines +16 to +18
for (Item item : items) {
UpdateLogic updateLogic = updateLogicFactory.getUpdateLogic(item);
updateLogic.update(item);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 for문을 향상된 for문으로 수정하여 가독성이 좋아진 것 같네요👍

Comment on lines 11 to 18
item.quality++;
if (item.sellIn < 11 && item.quality < 50) {
item.quality++;
}
if (item.sellIn < 6 && item.quality < 50) {
item.quality++;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가독성을 위해 10 이하, 5 이하로 바꿔보는것도 좋을 것 같습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants