260616_20_이종재#51
Conversation
메서드 오버라이딩 과제 검토 및 피드백전반적 평가축하합니다! 이번 과제에서는 상속(Inheritance), 메서드 오버라이딩(Method Overriding), **다형성(Polymorphism)**의 핵심 개념을 잘 이해하고 구현했습니다. 모든 JUnit 테스트가 통과했으며, 코드 구조도 명확합니다. 잘 구현된 부분1. 상속 구조의 명확성
2. 메서드 오버라이딩의 올바른 사용
3. 캡슐화 적용
4. 테스트 코드의 품질
개선 제안 (Socratic 피드백)1.
|
| Layer / File(s) | Summary |
|---|---|
day260608/day260609 Cleric 가시성 변경 day01-basic/src/main/java/com/survivalcoding/day260608/Cleric.java, day01-basic/src/main/java/com/survivalcoding/day260609/Cleric.java |
day260608 Cleric의 hp/mp/name 필드 및 selfAid/pray 메서드, day260609 Cleric의 maxHp/maxMp 상수·필드·생성자 세 개를 package-private에서 public으로 변경한다. |
day260615 소스 파일 패키지 선언 일괄 수정 day01-basic/src/main/java/com/survivalcoding/day260615/*.java, day01-basic/src/main/java/com/survivalcoding/day260615/game/build.gradle, settings.gradle |
day260615 디렉터리 내 13개 클래스 파일의 package 선언을 com.survivalcoding에서 com.survivalcoding.day260615로 변경하고, 잘못된 위치의 build.gradle 내용을 삭제하며 settings.gradle에서 game 모듈 포함을 제거한다. |
테스트 패키지 선언 수정 및 단언값 교정 day01-basic/src/test/java/com/survivalcoding/MainTest.java, day01-basic/src/test/java/com/survivalcoding/day260608/ClericTest.java, day01-basic/src/test/java/com/survivalcoding/day260609/MainTest.java, day01-basic/src/test/java/com/survivalcoding/day260615/*.java, TIL/sample/2026-06-15.md |
day260608/day260609 테스트의 중첩 패키지 오류를 수정하고, day260615 테스트 5개 파일을 올바른 패키지로 이동한다. ClericTest의 name 기대값을 수정하고, 최상위 MainTest를 제거하며, TIL 2026-06-15 노트를 추가한다. |
day260616 상속·오버라이딩·다형성 예제 신규 구현
| Layer / File(s) | Summary |
|---|---|
Hero·Slime·Wizard 기반 클래스 정의 day01-basic/src/main/java/com/survivalcoding/day260616/Hero.java, day01-basic/src/main/java/com/survivalcoding/day260616/Slime.java, day01-basic/src/main/java/com/survivalcoding/day260616/Wizard.java |
Hero(이름/체력/행동 메서드), Slime(이름/체력/attack), Wizard 추상 클래스(MP 검증·heal 로직)를 새로 추가한다. |
SuperHero·PoisonSlime·GreatWizard 서브클래스 및 Main day01-basic/src/main/java/com/survivalcoding/day260616/SuperHero.java, day01-basic/src/main/java/com/survivalcoding/day260616/PoisonSlime.java, day01-basic/src/main/java/com/survivalcoding/day260616/GreatWizard.java, day01-basic/src/main/java/com/survivalcoding/day260616/Main.java |
SuperHero는 isFlying 상태에 따라 run/attack을 오버라이드하고, PoisonSlime은 super.attack 후 poisonCount만큼 독 데미지를 추가 적용하며, GreatWizard는 heal을 오버라이드하고 superHeal을 추가한다. Main에서 Hero·SuperHero를 생성해 run()을 호출한다. |
GreatWizardTest·PoisonSlimeTest 및 TIL 2026-06-16 day01-basic/src/test/java/com/survivalcoding/day260616/GreatWizardTest.java, day01-basic/src/test/java/com/survivalcoding/day260616/PoisonSlimeTest.java, TIL/sample/2026-06-16.md |
GreatWizardTest는 heal/superHeal의 HP 회복·MP 소비와 MP 부족 시 무변화를 4개 테스트로 검증하고, PoisonSlimeTest는 일반 공격과 독 데미지 합산 결과를 검증한다. TIL 2026-06-16 노트가 추가된다. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Title check | PR 제목이 실제 변경 사항과 일치하지 않습니다. 제목은 '260616_20_이종재'로 학생 ID와 이름만 포함하고 있으며, 오버라이딩에 대한 실질적 변경 내용을 반영하지 못합니다. | PR 제목을 변경하여 주요 변경사항을 명확하게 반영해야 합니다. 예: '오버라이딩 과제: GreatWizard, SuperHero, PoisonSlime 클래스 추가' 또는 유사한 형식으로 수정하세요. | |
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description check | ✅ Passed | PR 설명이 제공된 템플릿 구조를 따르고 있으며, 과제 정보(오버라이딩), 체크리스트 항목 완료, 실행 결과 이미지, 어려웠던 점, 자체 평가를 모두 포함하고 있습니다. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ 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 @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@day01-basic/src/main/java/com/survivalcoding/day260616/Hero.java`:
- Around line 12-15: The attack method in the Hero class is incorrectly reducing
the attacker's own HP instead of the target Slime's HP. In the attack(Slime
slime) method body, change the line that currently decreases hp to instead
decrease the slime parameter's HP. This will ensure the attack damages the
intended target (the Slime) rather than harming the attacker, which will also
fix the inherited behavior in SuperHero.attack that calls super.attack(slime).
In `@day01-basic/src/main/java/com/survivalcoding/day260616/SuperHero.java`:
- Line 28: There is a typo in the output string within the SuperHero class where
"입혔따" should be corrected to "입혔다". Locate the System.out.println statement that
outputs the 5-point damage message and fix the typo by replacing the incorrect
Korean character sequence with the correct spelling. This is a user-facing
message so the correction is important for clarity.
In `@TIL/sample/2026-06-16.md`:
- Around line 133-136: The GreatWizard constructor example in the documentation
uses setMp(150) but the actual implementation uses super(150). Update the
constructor example in the GreatWizard class to use super(150) instead of
setMp(150) to align the documentation with the actual implementation and
maintain consistency in demonstrating inheritance constructor chaining patterns.
🪄 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: 527bdc8a-be71-4b6e-b6f1-23e9ebdd4b21
📒 Files selected for processing (36)
TIL/sample/2026-06-15.mdTIL/sample/2026-06-16.mdday01-basic/src/main/java/com/survivalcoding/day260608/Cleric.javaday01-basic/src/main/java/com/survivalcoding/day260609/Cleric.javaday01-basic/src/main/java/com/survivalcoding/day260615/Cleric.javaday01-basic/src/main/java/com/survivalcoding/day260615/EncapsulationExam.javaday01-basic/src/main/java/com/survivalcoding/day260615/GameConfig.javaday01-basic/src/main/java/com/survivalcoding/day260615/Hero.javaday01-basic/src/main/java/com/survivalcoding/day260615/Inn.javaday01-basic/src/main/java/com/survivalcoding/day260615/King.javaday01-basic/src/main/java/com/survivalcoding/day260615/Kinoko.javaday01-basic/src/main/java/com/survivalcoding/day260615/Main.javaday01-basic/src/main/java/com/survivalcoding/day260615/Person.javaday01-basic/src/main/java/com/survivalcoding/day260615/Quiz.javaday01-basic/src/main/java/com/survivalcoding/day260615/Sword.javaday01-basic/src/main/java/com/survivalcoding/day260615/Wand.javaday01-basic/src/main/java/com/survivalcoding/day260615/Wizard.javaday01-basic/src/main/java/com/survivalcoding/day260615/game/build.gradleday01-basic/src/main/java/com/survivalcoding/day260616/GreatWizard.javaday01-basic/src/main/java/com/survivalcoding/day260616/Hero.javaday01-basic/src/main/java/com/survivalcoding/day260616/Main.javaday01-basic/src/main/java/com/survivalcoding/day260616/PoisonSlime.javaday01-basic/src/main/java/com/survivalcoding/day260616/Slime.javaday01-basic/src/main/java/com/survivalcoding/day260616/SuperHero.javaday01-basic/src/main/java/com/survivalcoding/day260616/Wizard.javaday01-basic/src/test/java/com/survivalcoding/MainTest.javaday01-basic/src/test/java/com/survivalcoding/day260608/ClericTest.javaday01-basic/src/test/java/com/survivalcoding/day260609/MainTest.javaday01-basic/src/test/java/com/survivalcoding/day260615/ClericTest.javaday01-basic/src/test/java/com/survivalcoding/day260615/HeroTest.javaday01-basic/src/test/java/com/survivalcoding/day260615/PersonTest.javaday01-basic/src/test/java/com/survivalcoding/day260615/WandTest.javaday01-basic/src/test/java/com/survivalcoding/day260615/WizardTest.javaday01-basic/src/test/java/com/survivalcoding/day260616/GreatWizardTest.javaday01-basic/src/test/java/com/survivalcoding/day260616/PoisonSlimeTest.javasettings.gradle
💤 Files with no reviewable changes (2)
- day01-basic/src/main/java/com/survivalcoding/day260615/game/build.gradle
- day01-basic/src/test/java/com/survivalcoding/MainTest.java
| public void attack(Slime slime){ | ||
| System.out.println(name + "이 공격했다."); | ||
| hp -= 10; | ||
| } |
There was a problem hiding this comment.
기본 공격 대상이 잘못되었습니다.
Line 14에서 공격자가 자신의 HP를 감소시키고 있어, attack(Slime slime)의 기본 계약(대상에게 피해)이 깨집니다. 이 루트 문제 때문에 SuperHero.attack의 super.attack(slime)도 의도한 일반 피해를 보장하지 못합니다.
제안 수정안
public void attack(Slime slime){
System.out.println(name + "이 공격했다.");
- hp -= 10;
+ slime.setHp(slime.getHp() - 10);
}🤖 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 `@day01-basic/src/main/java/com/survivalcoding/day260616/Hero.java` around
lines 12 - 15, The attack method in the Hero class is incorrectly reducing the
attacker's own HP instead of the target Slime's HP. In the attack(Slime slime)
method body, change the line that currently decreases hp to instead decrease the
slime parameter's HP. This will ensure the attack damages the intended target
(the Slime) rather than harming the attacker, which will also fix the inherited
behavior in SuperHero.attack that calls super.attack(slime).
| super.attack(slime); | ||
| if(isFlying){ | ||
| slime.setHp(slime.getHp() - 5); | ||
| System.out.println("5포인트의 추가 피해를 입혔따"); |
There was a problem hiding this comment.
출력 문자열 오타를 수정해 주세요.
Line 28 "입혔따"는 "입혔다" 오타입니다. 사용자에게 노출되는 메시지라 정정하는 편이 좋습니다.
- System.out.println("5포인트의 추가 피해를 입혔따");
+ System.out.println("5포인트의 추가 피해를 입혔다");🤖 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 `@day01-basic/src/main/java/com/survivalcoding/day260616/SuperHero.java` at
line 28, There is a typo in the output string within the SuperHero class where
"입혔따" should be corrected to "입혔다". Locate the System.out.println statement that
outputs the 5-point damage message and fix the typo by replacing the incorrect
Korean character sequence with the correct spelling. This is a user-facing
message so the correction is important for clarity.
| public class GreatWizard extends Wizard { | ||
| public GreatWizard() { | ||
| setMp(150); | ||
| } |
There was a problem hiding this comment.
실습 코드 예시가 실제 구현과 달라 학습 포인트를 혼동시킬 수 있습니다.
GreatWizard 생성자 예시가 실제 코드(super(150))와 달라서, 상속 생성자 체이닝 학습 맥락이 어긋납니다. 문서 예시를 실제 구현과 맞춰 주세요.
문서 예시 정합성 수정안
public class GreatWizard extends Wizard {
public GreatWizard() {
- setMp(150);
+ super(150);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public class GreatWizard extends Wizard { | |
| public GreatWizard() { | |
| setMp(150); | |
| } | |
| public class GreatWizard extends Wizard { | |
| public GreatWizard() { | |
| super(150); | |
| } |
🤖 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 133 - 136, The GreatWizard constructor
example in the documentation uses setMp(150) but the actual implementation uses
super(150). Update the constructor example in the GreatWizard class to use
super(150) instead of setMp(150) to align the documentation with the actual
implementation and maintain consistency in demonstrating inheritance constructor
chaining patterns.
260616_20_이종재
📝 과제 정보
📋 체크리스트
📷 실행 결과 (또는 테스트 결과)
❓질문 및 어려웠던 점
mp가 있고 자식에도mp가 있으면getMp()와this.mp가 서로 다른 값을 볼 수 있다.🔄 자체 평가 & 회고