Skip to content

260616_07_문재원#54

Open
Clair93 wants to merge 6 commits into
SurvivalCodingCampus:student/07_문재원from
Clair93:master
Open

260616_07_문재원#54
Clair93 wants to merge 6 commits into
SurvivalCodingCampus:student/07_문재원from
Clair93:master

Conversation

@Clair93

@Clair93 Clair93 commented Jun 16, 2026

Copy link
Copy Markdown

260616_07_문재원

📝 과제 정보

  1. Slime 클래스를 작성하고, PoisonSlime 자식 클래스로 "독 공격" 추가하기
  2. Wizard heal 메서드가 자신의 mp를 소모하며 영웅의 hp를 회복
  3. Wizard 클래스를 상속받아 GreatWizard 자식 클래스를 만들고 heal 메서드 재정의와 superHeal 메서드 만들기
  • 교육 주제: 상속과 메서드 재정의

📋 체크리스트

  • 코드 컨벤션 준수 (Formatter 적용)
  • 모든 테스트 케이스 통과 (JUnit)

📷 실행 결과 (또는 테스트 결과)

game poisonslime Heal

❓질문 및 어려웠던 점

🔄 자체 평가 & 회고

  • 상속에 대해서 배웠던 기억이 있는데 정말 발만 담그고 왔던 것 같다.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Pull Request 리뷰 - 상속과 메서드 오버라이딩

🎯 전체 평가

상속과 다형성의 개념을 잘 이해하고 구현했습니다! WizardGreatWizardSlimePoisonSlime 상속 구조가 명확하며, @Override 어노테이션을 올바르게 사용했습니다. 테스트 케이스도 모두 통과하고 있습니다.


💡 개선 제안 (오류는 아니지만 고민해볼 점들)

1. 캡슐화 관점: Hero의 HP 제약

생각해볼 질문:

  • 현재 Hero.setHp(int hp)는 음수만 검증하고 있습니다.
  • 만약 게임에서 영웅의 HP가 maxHp(300)을 초과한다면 어떻게 될까요?
  • 예를 들어, 300 HP인 상태에서 heal(Hero hero)hero.setHp(hero.getHp() + 20)을 하면, HP가 320이 될 수 있습니다.
  • 힌트: setHp() 메서드에서 maxHp와의 관계를 고려한 검증을 추가하면 어떨까요?
// 현재: hero.setHp(hero.getHp() + 20) → HP 초과 가능
// 개선 방향: setHp에서 maxHp 초과 방지

2. 상속과 메서드 오버라이딩: PoisonSlime.attack() 로직

생각해볼 질문:

  • PoisonSlimeattack() 메서드를 다시 읽어보세요 (14-27줄).
  • poisonCount가 5에서 0으로 감소할 때, 마지막(5번째) 공격에서 어떤 일이 발생하나요?
  • 줄 16-23에서 if (poisonCount > 0)가 실행되고, 줄 24-26에서 if (poisonCount <= 0)도 바로 실행되지 않나요?
  • 힌트: 이 두 조건을 다시 검토해서, 독 포자 공격이 5번만 정확히 발생하는지 확인해보세요. (else if 사용을 고려해볼까요?)

3. 캡슐화: Hero 클래스의 검증 부재

생각해볼 질문:

  • Wizard.setName()은 이름 길이 검증이 있습니다 (3자 이상).
  • 반면 Hero.setName()은 검증이 없습니다.
  • 게임 설계 상 Hero의 이름도 유효한 값이어야 하지 않을까요?
  • 힌트: HerosetName() 메서드에도 적절한 검증을 추가하면 어떨까요?

4. 클래스 책임: Wizard와 GreatWizard의 중복 코드

생각해볼 질문:

  • Wizard.heal()GreatWizard.heal() 모두 다음과 같은 구조를 반복합니다:
    • MP 확인 → "마나가 부족합니다." 출력
    • MP 차감 → Hero HP 증가 → 메시지 출력
  • 이 공통 부분을 더 효율적으로 처리할 수 있을까요?
  • 힌트: 부모 클래스의 메서드에 "마나 확인과 소모" 부분을 두고, 자식 클래스에서는 "HP 증가량만" 다르게 처리하는 구조를 생각해보세요.

5. 접근 제어자: 패키지 설계

생각해볼 질문:

  • 현재 Wizard, GreatWizard, Slime, PoisonSlime의 생성자가 package-private(기본값)입니다.
  • 다른 패키지에서 이 클래스들을 사용하려면 어떻게 해야 할까요?
  • 힌트: 외부에서 사용 가능하게 하려면 public 생성자를 고려해야 하지 않을까요?

✅ 잘 구현된 부분

  • 메서드 오버라이딩: @Override 어노테이션을 올바르게 사용
  • 생성자 체이닝: super(name, hp, mp) 호출로 부모 초기화 제대로 함
  • 다형성 활용: super.attack(hero) 호출로 부모의 기본 공격 후 추가 기능 구현
  • 테스트 작성: 두 개의 테스트 클래스 모두 통과 (GreatWizardTest, PoisonSlimeTest)
  • 문서화: UML 다이어그램으로 클래스 구조 명확히 표현

📚 학습 포인트

이번 PR을 통해 상속, 메서드 오버라이딩, 캡슐화의 실제 관계를 경험하셨습니다. 특히 다음을 고민해보세요:

"부모 클래스는 기본 기능을, 자식 클래스는 그것을 확장하거나 특화하는가?"
"모든 필드와 메서드가 적절한 접근 제어자를 갖고 있는가?"

Walkthrough

Heroname/maxHp 필드와 접근자를 추가하고, Slime/PoisonSlimeWizard/GreatWizard 상속 계층을 신규 구현했다. Wizard 생성자에서 Wand 의존성을 제거하고 heal을 MP 기반으로 교체했다. PlantUML 다이어그램, JUnit5 테스트, TIL 학습 문서를 함께 추가했다.

Changes

Game 상속 구조 구현

Layer / File(s) Summary
Hero 필드/생성자/접근자 확장
game/src/main/java/com/survivalcoding/Hero.java
name, maxHp 필드와 기본값(300)을 추가하고, Hero(String, int) 생성자와 getName/setName/getMaxHp/setMaxHp 퍼블릭 메서드를 도입했다.
Slime/PoisonSlime 클래스 계층
game/src/main/java/com/survivalcoding/Slime.java, game/src/main/java/com/survivalcoding/PoisonSlime.java
Slimesuffix/hp 필드와 패키지-프라이빗 attack(Hero) 메서드를 추가하고, PoisonSlimepoisonCount 기반 독 데미지(hero.getHp()/5) 및 poisonCount 감소 로직으로 attack을 오버라이드한다.
Wizard 리팩토링 및 GreatWizard 구현
game/src/main/java/com/survivalcoding/Wizard.java, game/src/main/java/com/survivalcoding/GreatWizard.java
Wizard 생성자에서 Wand 파라미터를 제거하고 heal을 MP 10 소모/HP 20 회복 로직으로 교체했다. GreatWizardheal(MP 5 소모/HP +25)과 superHeal(MP 50 소모/HP 최대치 회복)을 구현한다.
PlantUML 클래스 다이어그램 갱신
game/game.puml
GreatWizard, Wizard, PoisonSlime, Slime, Hero의 상속 관계, 생성자/메서드 시그니처, 오버라이드 표시를 포함하도록 다이어그램 전체를 재구성했다.
JUnit5 테스트 추가 및 WizardTest 상수화
game/src/test/java/com/survivalcoding/WizardTest.java, game/src/test/java/com/survivalcoding/GreatWizardTest.java, game/src/test/java/com/survivalcoding/PoisonSlimeTest.java
WizardTest의 하드코딩 리터럴을 static final 상수로 분리하고 TWO_NAME"AB"로 변경했다. GreatWizardTestPoisonSlimeTest를 신규 추가하여 heal/superHeal의 MP·HP 변화와 독 공격 후 poisonCount 소진을 검증한다.

TIL 학습 문서 업데이트

Layer / File(s) Summary
TIL 문서 수정 및 상속 문서 추가
TIL/sample/2026-06-15-캡슐화-컬렉션.md, TIL/sample/2026-06-16-상속.md
2026-06-15 문서의 향상된 for문 설명 표현을 교정했으며, 2026-06-16 상속 문서를 신규 작성하여 extends/final/super/오버라이드 개념과 GreatWizard 예제 코드, 어려웠던 점을 기록했다.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant PoisonSlime
  participant Slime
  participant Hero

  rect rgba(255, 100, 100, 0.5)
    note over PoisonSlime,Hero: poisonCount > 0 구간
    Caller->>PoisonSlime: attack(hero)
    PoisonSlime->>Slime: super.attack(hero)
    Slime->>Hero: setHp(hp - 10)
    PoisonSlime->>Hero: setHp(hp - hp/5) 독 데미지
    PoisonSlime->>PoisonSlime: poisonCount--
  end

  rect rgba(100, 100, 255, 0.5)
    note over PoisonSlime,Hero: poisonCount <= 0 구간
    Caller->>PoisonSlime: attack(hero)
    PoisonSlime->>Slime: super.attack(hero)
    Slime->>Hero: setHp(hp - 10)
  end
Loading
sequenceDiagram
  participant Caller
  participant GreatWizard
  participant Wizard
  participant Hero

  rect rgba(100, 200, 100, 0.5)
    note over Wizard,Hero: Wizard.heal (mp >= 10)
    Caller->>Wizard: heal(hero)
    Wizard->>Wizard: mp -= 10
    Wizard->>Hero: setHp(hp + 20)
  end

  rect rgba(200, 150, 50, 0.5)
    note over GreatWizard,Hero: GreatWizard.heal (mp >= 5)
    Caller->>GreatWizard: heal(hero)
    GreatWizard->>GreatWizard: mp -= 5
    GreatWizard->>Hero: setHp(hp + 25)
  end

  rect rgba(150, 50, 200, 0.5)
    note over GreatWizard,Hero: GreatWizard.superHeal (mp >= 50)
    Caller->>GreatWizard: superHeal(hero)
    GreatWizard->>GreatWizard: mp -= 50
    GreatWizard->>Hero: setHp(getMaxHp())
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning PR 제목 '260616_07_문재원'은 저장소의 명명 규칙(YYMMDD_번호_작성자명)을 따르지만, 실제 변경 사항의 핵심 내용(상속과 메서드 오버라이딩, Slime/PoisonSlime/GreatWizard 구현)을 설명하지 못합니다. 제목을 '상속과 메서드 오버라이딩: Slime, PoisonSlime, GreatWizard 구현' 등으로 변경하여 주요 변경 내용을 명확히 드러내세요.
Docstring Coverage ⚠️ Warning 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 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 6-7: Fix the typo in the GreatWizard constructor notation on line
7 where the super call contains `np` which should be `mp` to match the parameter
defined on line 6. Additionally, reformat the constructor signature for the
GreatWizard class to clearly and consistently represent the full constructor
declaration including its parameters, parent class invocation with the corrected
parameter name, and method calls, ensuring the PlantUML diagram matches the
actual code signature.

In `@game/src/main/java/com/survivalcoding/Hero.java`:
- Around line 25-27: The setMaxHp method in the Hero class does not validate its
input or maintain the Hero state invariant that hp should never exceed maxHp.
Add validation to ensure the new maxHp is non-negative (maxHp >= 0), and if the
current hp exceeds the new maxHp after assignment, reduce hp to equal the new
maxHp value. This prevents violations of the Hero state invariant that could
cause issues in downstream code like GreatWizard.superHeal().

In `@game/src/main/java/com/survivalcoding/PoisonSlime.java`:
- Around line 16-26: The issue is that when poisonCount equals 1, both the first
if block (poisonCount > 0) and the second if block (poisonCount <= 0) execute in
the same turn, causing super.attack(hero) to be called twice. The first block
decrements poisonCount to 0, which then satisfies the second condition. Fix this
by changing the second if statement to else if, so that only one attack path is
executed per method call. Specifically, replace the second if (poisonCount <= 0)
condition with else if (poisonCount <= 0) to ensure the basic attack only
executes when there is no poison attack in that turn.

In `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java`:
- Around line 30-35: The Count test method only verifies that
poisonSlime.getPoisonCount() reaches zero after five attacks, but it does not
validate that the hero's HP actually decreased from those attacks. This means
the attack logic could be broken and the test would still pass. Capture the
hero's initial HP before the attack loop, then after the loop add an
assertEquals assertion to verify that hero.getHp() has been reduced by the
expected poison damage amount, ensuring both the poison count depletion and the
actual damage dealt are properly validated.

In `@TIL/sample/2026-06-16-상속.md`:
- Around line 60-68: The TIL documentation has method signatures that differ
from the actual project implementation. At TIL/sample/2026-06-16-상속.md lines
60-68, update the heal() method signature to accept a Hero parameter as
heal(Hero hero), and change the method body to call hero.setHp(hero.getHp() +
25) instead of setHp(getHp() + 25). Similarly, at TIL/sample/2026-06-16-상속.md
lines 70-79, update the superHeal() method signature to accept a Hero parameter
as superHeal(Hero hero), and change the method body to call
hero.setHp(hero.getMaxHp()) to restore the Hero's HP to maximum. These changes
align the TIL documentation with the actual implementation in
game/src/main/java/com/survivalcoding/GreatWizard.java and its corresponding
test cases.
- Line 33: The code example for the attack() method at line 33 is incomplete and
malformed with an improper comment notation "<<" that breaks the code syntax.
Replace this incomplete line with a complete, well-formed code example that
demonstrates method overriding with a proper `@Override` annotation, a complete
method signature including parameters if needed, a call to the parent class
method using super.attack(), and proper closing braces. Ensure the example is
syntactically correct and clearly illustrates the inheritance concept being
documented.
🪄 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: 8894ce07-97bf-420d-b014-15f9a7685bf9

📥 Commits

Reviewing files that changed from the base of the PR and between f8fe629 and 51fc702.

⛔ Files ignored due to path filters (1)
  • game/game.png is excluded by !**/*.png
📒 Files selected for processing (11)
  • TIL/sample/2026-06-15-캡슐화-컬렉션.md
  • TIL/sample/2026-06-16-상속.md
  • game/game.puml
  • game/src/main/java/com/survivalcoding/GreatWizard.java
  • game/src/main/java/com/survivalcoding/Hero.java
  • game/src/main/java/com/survivalcoding/PoisonSlime.java
  • game/src/main/java/com/survivalcoding/Slime.java
  • game/src/main/java/com/survivalcoding/Wizard.java
  • game/src/test/java/com/survivalcoding/GreatWizardTest.java
  • game/src/test/java/com/survivalcoding/PoisonSlimeTest.java
  • game/src/test/java/com/survivalcoding/WizardTest.java

Comment thread game/game.puml
Comment on lines +6 to +7
+GreatWizard(String:name, int:hp, int:mp
<<super(name,hp,np)>>, setMp(150))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

GreatWizard 생성자 표기 오타(np)와 시그니처 표현이 코드와 불일치합니다.

Line 7의 super(name,hp,np)mp 오타이고, 현재 줄바꿈 형태도 생성자 시그니처를 잘못 읽히게 만듭니다. 다이어그램을 코드 시그니처와 동일하게 정리해 주세요.

🔧 제안 수정안
-    +GreatWizard(String:name, int:hp, int:mp
-    <<super(name,hp,np)>>, setMp(150))
+    +GreatWizard(String:name, int:hp, int:mp, <<super(name,hp,mp)>>, setMp(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.

Suggested change
+GreatWizard(String:name, int:hp, int:mp
<<super(name,hp,np)>>, setMp(150))
GreatWizard(String:name, int:hp, int:mp, <<super(name,hp,mp)>>, setMp(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 `@game/game.puml` around lines 6 - 7, Fix the typo in the GreatWizard
constructor notation on line 7 where the super call contains `np` which should
be `mp` to match the parameter defined on line 6. Additionally, reformat the
constructor signature for the GreatWizard class to clearly and consistently
represent the full constructor declaration including its parameters, parent
class invocation with the corrected parameter name, and method calls, ensuring
the PlantUML diagram matches the actual code signature.

Comment on lines +25 to +27
public void setMaxHp(int maxHp) {
this.maxHp = maxHp;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

setMaxHp가 Hero 상태 불변식을 깨뜨릴 수 있습니다.

Line 25-27에서 maxHp를 그대로 대입하면 음수 값이나 현재 HP보다 작은 값이 들어갈 수 있고, 이후 GreatWizard.superHeal(...)(game/src/main/java/com/survivalcoding/GreatWizard.java Line 27) 경로에서 예외/비정상 상태로 이어질 수 있습니다. maxHp >= 0 검증과 hp <= maxHp 보정을 함께 넣는 편이 안전합니다.

🔧 제안 수정안
 public void setMaxHp(int maxHp) {
-    this.maxHp = maxHp;
+    if (maxHp < 0) {
+        throw new IllegalArgumentException("최대 HP는 0 이상이어야 합니다.");
+    }
+    this.maxHp = maxHp;
+    if (this.hp > maxHp) {
+        this.hp = maxHp;
+    }
 }
 public void setHp(int hp) {
     if (hp < 0) {
         throw new IllegalArgumentException("HP는 0 이상이어야 합니다.");
     }
-    this.hp = hp;
+    this.hp = Math.min(hp, maxHp);
 }
🤖 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 25 - 27, The
setMaxHp method in the Hero class does not validate its input or maintain the
Hero state invariant that hp should never exceed maxHp. Add validation to ensure
the new maxHp is non-negative (maxHp >= 0), and if the current hp exceeds the
new maxHp after assignment, reduce hp to equal the new maxHp value. This
prevents violations of the Hero state invariant that could cause issues in
downstream code like GreatWizard.superHeal().

Comment on lines +16 to +26
if (poisonCount > 0) {
super.attack(hero);
System.out.println("추가로, 독 포자를 살포했다!");
int poisonDamage = hero.getHp() / 5;
hero.setHp(hero.getHp() - poisonDamage);
System.out.println(poisonDamage + "포인트 데미지");
poisonCount--;
}
if (poisonCount <= 0) {
super.attack(hero);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

독 카운트가 1일 때 기본 공격이 한 번 더 적용됩니다.

Line 16-26은 poisonCount == 1인 호출에서 첫 번째 블록 실행 후 poisonCount--로 0이 되고, 바로 아래 조건도 참이 되어 super.attack(hero)가 같은 턴에 2회 실행됩니다.

🔧 제안 수정안
 `@Override`
 void attack(Hero hero) {
     if (poisonCount > 0) {
         super.attack(hero);
         System.out.println("추가로, 독 포자를 살포했다!");
         int poisonDamage = hero.getHp() / 5;
         hero.setHp(hero.getHp() - poisonDamage);
         System.out.println(poisonDamage + "포인트 데미지");
         poisonCount--;
-    }
-    if (poisonCount <= 0) {
+        return;
+    }
+    if (poisonCount <= 0) {
         super.attack(hero);
     }
 }
🤖 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/PoisonSlime.java` around lines 16 - 26,
The issue is that when poisonCount equals 1, both the first if block
(poisonCount > 0) and the second if block (poisonCount <= 0) execute in the same
turn, causing super.attack(hero) to be called twice. The first block decrements
poisonCount to 0, which then satisfies the second condition. Fix this by
changing the second if statement to else if, so that only one attack path is
executed per method call. Specifically, replace the second if (poisonCount <= 0)
condition with else if (poisonCount <= 0) to ensure the basic attack only
executes when there is no poison attack in that turn.

Comment on lines +30 to +35
void Count() {
for (int i = 0; i < 5; i++) {
poisonSlime.attack(hero);
}

assertEquals(0, poisonSlime.getPoisonCount());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Count 테스트가 HP 회귀를 검출하지 못합니다.

현재는 poisonCount만 검증해서, 공격 로직이 잘못되어도 테스트가 통과할 수 있습니다. hero.getHp()도 함께 단정해 독 소진 전/후 피해 계약을 고정해 주세요.

🔧 제안 패치
     `@Test`
     `@DisplayName`("poisonCount가 0이 되어야 한다.")
     void Count() {
         for (int i = 0; i < 5; i++) {
             poisonSlime.attack(hero);
         }

         assertEquals(0, poisonSlime.getPoisonCount());
+        assertEquals(40, hero.getHp()); // 5회 공격 후 기대 HP(독 5회 적용)
+
+        poisonSlime.attack(hero);
+        assertEquals(30, hero.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 `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java` around lines 30 -
35, The Count test method only verifies that poisonSlime.getPoisonCount()
reaches zero after five attacks, but it does not validate that the hero's HP
actually decreased from those attacks. This means the attack logic could be
broken and the test would still pass. Capture the hero's initial HP before the
attack loop, then after the loop add an assertEquals assertion to verify that
hero.getHp() has been reduced by the expected poison damage amount, ensuring
both the poison count depletion and the actual damage dealt are properly
validated.


- 메서드도 부모 클래스에 final 이 있다면 상속을 막을 수 있다.
- public final void slip()
- public void attack() { super.attack(); << 상속 받은 것.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

불완전한 코드 예제를 수정하세요.

라인 33의 코드 조각이 미완성 상태입니다. 주석 표기 "<<" 가 있고 메서드 본문이 제대로 작성되지 않았습니다. 명확한 예제 코드로 교체하거나 설명 텍스트로 변경하는 것이 좋습니다.

💡 개선 제안

라인 33을 다음과 같이 개선할 수 있습니다:

-    - public void attack() { super.attack(); << 상속 받은 것.
+    - 예: `super.attack();` 로 부모 클래스의 메서드를 호출할 수 있습니다.

또는 완전한 예제:

`@Override`
void attack(Hero hero) {
    super.attack(hero);  // 부모 클래스의 attack 호출
    // 추가 로직...
}
🤖 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` at line 33, The code example for the attack()
method at line 33 is incomplete and malformed with an improper comment notation
"<<" that breaks the code syntax. Replace this incomplete line with a complete,
well-formed code example that demonstrates method overriding with a proper
`@Override` annotation, a complete method signature including parameters if
needed, a call to the parent class method using super.attack(), and proper
closing braces. Ensure the example is syntactically correct and clearly
illustrates the inheritance concept being documented.

Comment on lines +60 to +68
void heal() {
if (getMp() < 5) {
System.out.println("마나가 부족합니다.");
} else {
setMp(getMp() - 5);
setHp(getHp() + 25);
System.out.println("힐을 시전했습니다. " + getName() + " HP : " + getHp());
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

TIL 실습 코드의 메서드 시그니처가 실제 구현과 불일치합니다. TIL 문서의 GreatWizard 예제는 Hero 파라미터 없이 작성되었으나, 실제 game/src/main/java/com/survivalcoding/GreatWizard.java와 테스트 케이스(game/src/test/java/com/survivalcoding/GreatWizardTest.java)에서는 모두 Hero 파라미터를 요구합니다. 이러한 불일치는 학습자가 작성한 코드와 실제 프로젝트 코드 사이에 큰 혼동을 초래할 수 있습니다.

  • TIL/sample/2026-06-16-상속.md#L60-L68: heal() 메서드 시그니처를 heal(Hero hero)로 수정하고, 메서드 본문에서 hero.setHp(hero.getHp() + 25)로 변경하여 실제 구현을 반영합니다.
  • TIL/sample/2026-06-16-상속.md#L70-L79: superHeal() 메서드 시그니처를 superHeal(Hero hero)로 수정하고, hero.setHp(hero.getMaxHp())로 수정하여 Hero의 HP를 최대값으로 복구하도록 합니다.
📍 Affects 1 file
  • TIL/sample/2026-06-16-상속.md#L60-L68 (this comment)
  • TIL/sample/2026-06-16-상속.md#L70-L79
🤖 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 60 - 68, The TIL documentation has
method signatures that differ from the actual project implementation. At
TIL/sample/2026-06-16-상속.md lines 60-68, update the heal() method signature to
accept a Hero parameter as heal(Hero hero), and change the method body to call
hero.setHp(hero.getHp() + 25) instead of setHp(getHp() + 25). Similarly, at
TIL/sample/2026-06-16-상속.md lines 70-79, update the superHeal() method signature
to accept a Hero parameter as superHeal(Hero hero), and change the method body
to call hero.setHp(hero.getMaxHp()) to restore the Hero's HP to maximum. These
changes align the TIL documentation with the actual implementation in
game/src/main/java/com/survivalcoding/GreatWizard.java and its corresponding
test cases.

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.

1 participant