26_06_16_13_김진용#52
Conversation
상속 과제 리뷰🎯 잘한 점1. 상속 구조의 올바른 이해와 구현PoisonSlime이 Slime을 확장하고, GreatWizard가 Wizard를 확장하는 계층 구조가 명확하고 의도가 잘 드러나 있습니다. 특히 2. 다형성의 실제 활용
3. 적절한 캡슐화모든 필드를 private으로 선언하고 getter/setter를 통해 접근하도록 했습니다. Wizard의 4. 테스트 코드 작성PoisonSlimeTest에서 공격 후 HP 감소와 poisonCount 감소를 검증하고 있으며, 준비-실행-검증의 AAA 패턴을 잘 따르고 있습니다. 💭 생각해볼 점1. 메서드 접근 제어자의 일관성Slime과 Wizard의
2. Hero 클래스의 데이터 보호Wizard의
3. PoisonSlime의 독 포자 데미지 계산int poisonDamage = hero.getHP() / 5;
hero.setHP(hero.getHP() - poisonDamage);현재 코드는 현재의 HP를 기반으로 독 데미지를 계산합니다.
4. 생성자 체인의 이해GreatWizard의 생성자에서
5. PlantUML 다이어그램과 실제 코드의 정합성다이어그램에서는 Wizard의 일부 메서드가 패키지 접근(~)으로 표시되어 있습니다.
✨ 제안
📝 종합 평가상속의 기본 개념을 탄탄하게 이해하고 있으며, 실제 게임 도메인 모델을 통해 이를 구현했습니다. 코드 포매팅도 잘되어 있고 테스트도 작성했다는 점이 훌륭합니다. 위의 피드백들을 검토하며 더욱 견고한 설계로 개선한다면, 캡슐화와 상속이라는 객체지향의 핵심을 더욱 깊이 있게 이해할 수 있을 것입니다. 고생하셨습니다! 🎉 Walkthrough
Changes상속 계층 구현 및 문서화
Sequence Diagram(s)sequenceDiagram
rect rgba(135, 206, 235, 0.5)
Note over PoisonSlimeTest,Hero: PoisonSlime 공격 흐름
PoisonSlimeTest->>PoisonSlime: attack(hero)
PoisonSlime->>Slime: super.attack(hero)
Slime->>Hero: setHP(getHP() - 10)
PoisonSlime->>Hero: getHP()
PoisonSlime->>Hero: setHP(getHP() - poisonDamage)
PoisonSlime->>PoisonSlime: poisonCount--
end
rect rgba(144, 238, 144, 0.5)
Note over GreatWizardTest,Hero: GreatWizard 힐 흐름
GreatWizardTest->>GreatWizard: heal(hero)
GreatWizard->>GreatWizard: mp -= 5
GreatWizard->>Hero: setHP(getHP() + 25)
GreatWizardTest->>GreatWizard: superHeal(hero)
GreatWizard->>GreatWizard: mp -= 50
GreatWizard->>Hero: setHP(getMaxHP())
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (3)
TIL/sample/2026-06-16-상속.md (2)
71-78: 💤 Low valuePlantUML 학습 내용 추가 제안.
"어려웠던 점" 섹션에 PlantUML 변환 오류를 언급했으나, 해결책이 "AI의 도움"으로만 기술되어 있습니다. 구체적으로 어떤 오류(문법, 관계 표현 등)가 발생했으며 어떻게 해결했는지 더 상세히 기록하면 나중에 참고하기 좋습니다.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@TIL/sample/2026-06-16-상속.md` around lines 71 - 78, In the "해결 방법" (Solution) section, replace the vague statement "AI의 도움을 받았다" with specific details about the PlantUML errors encountered (such as syntax errors, incorrect relationship notation, etc.) and the concrete steps taken to resolve each error. Document the actual solutions applied rather than just mentioning AI assistance, so the learning experience is captured for future reference.
12-13: 💤 Low value표현 개선: 상속 관계 설명.
라인 12의 "개념적으로 is-a관계가 되지 못 함에도 불구하고"는 다소 애매합니다. 예를 들어 "펭귄이 새인가? 맞다. 하지만 새가 날 수 있는가? 아니다. 이처럼 현실 세계와 모순되는 상속은 피해야 한다"처럼 구체적으로 작성하면 더 명확합니다.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@TIL/sample/2026-06-16-상속.md` around lines 12 - 13, The expression on line 12 about "개념적으로 is-a관계가 되지 못 함에도 불구하고" is too vague and unclear. Replace this vague abstract explanation with a concrete real-world example to illustrate the concept better. Use the specific example provided in the comment: explain that while a penguin is indeed a bird (is-a relationship exists), a bird cannot necessarily fly, thus demonstrating how inheritance that contradicts reality should be avoided. This concrete example will make the explanation of why improper inheritance violates the polymorphism principle much clearer to readers.game/src/test/java/com/survivalcoding/PoisonSlimeTest.java (1)
9-28: 💤 Low value테스트 주석 가독성 개선.
테스트가 논리적으로 정확하지만, "준비-실행-검증" 주석이 직관적이지 않습니다. 각 단계에서 어떤 값이 기대되는지 더 명확하게 작성하세요.
예: "// 첫 공격 후: super.attack()으로 -10, 독 데미지 18 (90/5) → HP 72 예상"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java` around lines 9 - 28, Replace the generic "준비-실행-검증" comments in the attack() test method with more descriptive comments that explain the expected values and calculation logic. For each attack phase, add comments that clarify the damage calculation (such as base damage minus poison damage based on poison count divided by 5) and the resulting expected HP value. This makes the test more self-documenting and helps future readers understand why specific HP and poison count values are being asserted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@game/game.puml`:
- Around line 51-65: Add missing inheritance relationships between the character
classes and the Person base class in the PlantUML diagram. In the Wizard class
definition (lines 51-65), add a PlantUML inheritance relationship to show that
Wizard extends Person using the appropriate PlantUML syntax. Additionally, apply
the same inheritance relationship fix to the Cleric class at lines 18-26 if it
also should inherit from Person. Use the standard PlantUML notation to define
these parent-child relationships so that the diagram properly reflects that both
Wizard and Cleric are subclasses of Person.
In `@game/src/main/java/com/survivalcoding/Exercise.java`:
- Around line 17-24: Clarify the comments in the Exercise.java file (lines
17-24) by explicitly explaining the context of each exercise. For "26_06_16 연습문제
1", add a note clarifying which of the choices (2,3,5) corresponds to which data
structure (set, list, map) from the exercise answers. For "연습문제 2", rewrite the
is-a mappings to make it explicit that these represent waste disposal
classification hierarchies rather than standard OOP inheritance, for example by
prefixing with a comment like "폐기물 처리 관점:" to clarify that "BMW → Car → 고철" is a
disposal category mapping, not a typical object-oriented inheritance hierarchy.
In `@game/src/main/java/com/survivalcoding/Hero.java`:
- Around line 8-11: The Hero class does not validate HP and MaxHP values,
allowing invalid states such as HP < 0, MaxHP <= 0, or HP > MaxHP. Add
validation constraints in all three locations where these fields are assigned.
In the constructor (Hero method at lines 8-11), validate that HP is non-negative
and that MaxHP is positive. At the second assignment location (lines 17-19),
validate the invariant for whichever field is being set. At the third assignment
location (lines 38-40), apply the same validation rules for the field being
modified. Ensure that whenever HP or MaxHP is set, the resulting state
satisfies: HP >= 0, MaxHP > 0, and HP <= MaxHP.
In `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java`:
- Line 15: The variable nattack is declared on line 15 in the PoisonSlimeTest
class but is never used anywhere in the code. Remove the unused variable
declaration `int nattack;` to clean up the code and eliminate the warning about
the unused variable.
---
Nitpick comments:
In `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java`:
- Around line 9-28: Replace the generic "준비-실행-검증" comments in the attack() test
method with more descriptive comments that explain the expected values and
calculation logic. For each attack phase, add comments that clarify the damage
calculation (such as base damage minus poison damage based on poison count
divided by 5) and the resulting expected HP value. This makes the test more
self-documenting and helps future readers understand why specific HP and poison
count values are being asserted.
In `@TIL/sample/2026-06-16-상속.md`:
- Around line 71-78: In the "해결 방법" (Solution) section, replace the vague
statement "AI의 도움을 받았다" with specific details about the PlantUML errors
encountered (such as syntax errors, incorrect relationship notation, etc.) and
the concrete steps taken to resolve each error. Document the actual solutions
applied rather than just mentioning AI assistance, so the learning experience is
captured for future reference.
- Around line 12-13: The expression on line 12 about "개념적으로 is-a관계가 되지 못 함에도
불구하고" is too vague and unclear. Replace this vague abstract explanation with a
concrete real-world example to illustrate the concept better. Use the specific
example provided in the comment: explain that while a penguin is indeed a bird
(is-a relationship exists), a bird cannot necessarily fly, thus demonstrating
how inheritance that contradicts reality should be avoided. This concrete
example will make the explanation of why improper inheritance violates the
polymorphism principle much clearer to readers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 044533e6-fa56-4eef-9caf-43e08c384d01
📒 Files selected for processing (11)
TIL/sample/2026-06-16-상속.mdgame/game.pumlgame/src/main/java/com/survivalcoding/Exercise.javagame/src/main/java/com/survivalcoding/GreatWizard.javagame/src/main/java/com/survivalcoding/Hero.javagame/src/main/java/com/survivalcoding/PoisonSlime.javagame/src/main/java/com/survivalcoding/Slime.javagame/src/main/java/com/survivalcoding/Wizard.javagame/src/test/java/com/survivalcoding/GreatWizardTest.javagame/src/test/java/com/survivalcoding/PoisonSlimeTest.javagame/src/test/java/com/survivalcoding/WizardTest.java
| class Wizard { | ||
| -wand : Wand | ||
| -hp : int | ||
| -mp : int | ||
| -name : String | ||
| ~heal(hero: Hero) : void | ||
| +getWand() : Wand | ||
| +setWand(wand: Wand) : void | ||
| +getHp() : int | ||
| +setHp(hp: int) : void | ||
| +getMp() : int | ||
| +setMp(mp: int) : void | ||
| +getName() : String | ||
| +setName(name: String) : void | ||
| } |
There was a problem hiding this comment.
Wizard와 Person 간 상속 관계 누락.
PlantUML 다이어그램에서 Person 클래스는 정의되어 있지만, Wizard가 Person을 상속하는 관계(extends)가 표현되지 않았습니다. 리뷰 스택 컨텍스트에 따르면 Wizard는 Person을 상속해야 합니다.
다음을 추가하세요:
Wizard <|-- Person : 상속 (extends)
또한 Cleric도 Person을 상속하는 경우, 같은 방식으로 표현하세요.
Also applies to: 18-26
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@game/game.puml` around lines 51 - 65, Add missing inheritance relationships
between the character classes and the Person base class in the PlantUML diagram.
In the Wizard class definition (lines 51-65), add a PlantUML inheritance
relationship to show that Wizard extends Person using the appropriate PlantUML
syntax. Additionally, apply the same inheritance relationship fix to the Cleric
class at lines 18-26 if it also should inherit from Person. Use the standard
PlantUML notation to define these parent-child relationships so that the diagram
properly reflects that both Wizard and Cleric are subclasses of Person.
| /* | ||
| 26_06_16 연습문제 1 | ||
| 2,3,5 | ||
| 연습문제2 | ||
| (1) 아이폰 -> Phone -> 기계 | ||
| (2) BMW -> Car -> 고철 | ||
| (3) 종이 한자 사전 -> Dictionary -> 폐지 | ||
| */ |
There was a problem hiding this comment.
연습문제 주석: 문맥 명확화 필요.
라인 17-24의 주석이 명확하지 않습니다:
- "26_06_16 연습문제 1"에서 제시된 선택지(2,3,5)가 앞의 연습문제 1 답(set, list, map)과 어떤 관계인지 불명확합니다.
- "연습문제 2"의 is-a 매핑에서 "BMW → Car → 고철"은 일반적인 OOP 상속 계층(Car → Vehicle → Object)과 다릅니다. 이것이 폐기물 처리 분류를 의도한 것이라면, 주석을 더 명확히 하세요.
예: // 폐기물 처리 관점: BMW is-a Car is-a 고철
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@game/src/main/java/com/survivalcoding/Exercise.java` around lines 17 - 24,
Clarify the comments in the Exercise.java file (lines 17-24) by explicitly
explaining the context of each exercise. For "26_06_16 연습문제 1", add a note
clarifying which of the choices (2,3,5) corresponds to which data structure
(set, list, map) from the exercise answers. For "연습문제 2", rewrite the is-a
mappings to make it explicit that these represent waste disposal classification
hierarchies rather than standard OOP inheritance, for example by prefixing with
a comment like "폐기물 처리 관점:" to clarify that "BMW → Car → 고철" is a disposal
category mapping, not a typical object-oriented inheritance hierarchy.
| public Hero(String name, int HP) { | ||
| this.name = name; | ||
| this.HP = HP; | ||
| } |
There was a problem hiding this comment.
Hero의 HP/MaxHP 불변식이 보장되지 않습니다.
Line 8-11, Line 17-19, Line 38-40에서 값 검증 없이 대입되어 HP < 0, MaxHP <= 0, HP > MaxHP 상태가 가능합니다. Slime.attack와 GreatWizard.superHeal이 이 계약에 의존하므로 Hero에서 경계를 강제하는 게 안전합니다.
제안 수정안
public class Hero {
private String name;
private int HP;
private int MaxHP = 100;
public Hero(String name, int HP) {
- this.name = name;
- this.HP = HP;
+ this.name = name;
+ setHP(HP);
}
@@
public void setHP(int HP) {
- this.HP = HP;
+ if (HP < 0) {
+ this.HP = 0;
+ return;
+ }
+ this.HP = Math.min(HP, this.MaxHP);
}
@@
public void setMaxHP(int maxHP) {
- MaxHP = maxHP;
+ if (maxHP <= 0) {
+ throw new IllegalArgumentException("MaxHP는 1 이상이어야 합니다.");
+ }
+ MaxHP = maxHP;
+ if (this.HP > MaxHP) {
+ this.HP = MaxHP;
+ }
}
}Also applies to: 17-19, 38-40
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@game/src/main/java/com/survivalcoding/Hero.java` around lines 8 - 11, The
Hero class does not validate HP and MaxHP values, allowing invalid states such
as HP < 0, MaxHP <= 0, or HP > MaxHP. Add validation constraints in all three
locations where these fields are assigned. In the constructor (Hero method at
lines 8-11), validate that HP is non-negative and that MaxHP is positive. At the
second assignment location (lines 17-19), validate the invariant for whichever
field is being set. At the third assignment location (lines 38-40), apply the
same validation rules for the field being modified. Ensure that whenever HP or
MaxHP is set, the resulting state satisfies: HP >= 0, MaxHP > 0, and HP <=
MaxHP.
| String name = "모험가"; | ||
| String suffix = "A"; | ||
| int hp = 100; | ||
| int nattack; |
There was a problem hiding this comment.
선언되지 않은 변수 nattack 제거.
라인 15의 int nattack; 변수가 선언되었으나 사용되지 않습니다. 제거하세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java` at line 15, The
variable nattack is declared on line 15 in the PoisonSlimeTest class but is
never used anywhere in the code. Remove the unused variable declaration `int
nattack;` to clean up the code and eliminate the warning about the unused
variable.
26_06_16_13_김진용
📝 과제 정보
📋 체크리스트
📷 실행 결과 (또는 테스트 결과)
❓질문 및 어려웠던 점
상속하고 웬래 코드를 plantUML로 바꾸는 것이 어려웠다
🔄 자체 평가 & 회고