Skip to content

26_06_16_13_김진용#52

Open
KJY-1204 wants to merge 4 commits into
SurvivalCodingCampus:student/13_김진용from
KJY-1204:master
Open

26_06_16_13_김진용#52
KJY-1204 wants to merge 4 commits into
SurvivalCodingCampus:student/13_김진용from
KJY-1204:master

Conversation

@KJY-1204

Copy link
Copy Markdown

26_06_16_13_김진용

📝 과제 정보

  • 교육 주제: 상속

📋 체크리스트

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

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

26_06_16

❓질문 및 어려웠던 점

상속하고 웬래 코드를 plantUML로 바꾸는 것이 어려웠다

🔄 자체 평가 & 회고

  • 이번 과제를 통해 새롭게 알게 된 점이나 아쉬운 점을 기록합니다.
  • 평소보다 과제를 늦게 끝내 아쉽다

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

상속 과제 리뷰

🎯 잘한 점

1. 상속 구조의 올바른 이해와 구현

PoisonSlime이 Slime을 확장하고, GreatWizard가 Wizard를 확장하는 계층 구조가 명확하고 의도가 잘 드러나 있습니다. 특히 super.attack(hero) 호출로 부모의 기본 행동을 먼저 실행한 후 자식의 추가 행동을 구현하는 방식은 상속의 핵심을 잘 이해하고 있음을 보여줍니다.

2. 다형성의 실제 활용

heal() 메서드를 Wizard와 GreatWizard에서 오버라이드하여, 같은 메서드명으로 다른 동작을 수행하게 했습니다. 이는 다형성이 실제로 어떻게 작동하는지 보여주는 좋은 예시입니다.

3. 적절한 캡슐화

모든 필드를 private으로 선언하고 getter/setter를 통해 접근하도록 했습니다. Wizard의 setMp()에서 음수 값 검증을, setName()에서 null 검사와 길이 검증을 하는 등 입력 값을 보호하려는 의식이 좋습니다.

4. 테스트 코드 작성

PoisonSlimeTest에서 공격 후 HP 감소와 poisonCount 감소를 검증하고 있으며, 준비-실행-검증의 AAA 패턴을 잘 따르고 있습니다.


💭 생각해볼 점

1. 메서드 접근 제어자의 일관성

Slime과 Wizard의 attack() / heal() 메서드가 package-private(접근 제어자 없음)으로 선언되어 있습니다. 다음 질문을 고민해봅시다:

  • 이 메서드들이 같은 패키지 내 다른 클래스에서도 호출될 필요가 있을까요?
  • 만약 Hero가 직접 Slime을 공격하려면 어떻게 해야 할까요?
  • 현재의 접근 제어 수준이 이 클래스의 책임과 역할에 맞게 설계되었는지 검토해보세요.

2. Hero 클래스의 데이터 보호

Wizard의 setHp()는 음수 값을 0으로 보정하여 HP가 음수가 되지 않도록 보호하지만, Hero의 setHP()는 이러한 검증이 없습니다.

  • HP가 음수로 설정될 수 있다면, 게임 로직상 문제가 될 수 있지 않을까요?
  • 두 클래스의 데이터 보호 정책이 다른 이유가 있을까요?
  • Hero와 Wizard의 setHP/setHp 메서드를 비교해보며, 더 견고한 설계를 생각해보세요.

3. PoisonSlime의 독 포자 데미지 계산

int poisonDamage = hero.getHP() / 5;
hero.setHP(hero.getHP() - poisonDamage);

현재 코드는 현재의 HP를 기반으로 독 데미지를 계산합니다.

  • 매 공격마다 hero의 HP가 낮아지면, 독 피해도 줄어들게 됩니다. 이것이 의도된 설계인가요?
  • 아니라면, 초기 HP나 MaxHP를 기반으로 계산하는 것이 더 나을까요?
  • 게임 밸런스 관점에서 어떤 방식이 더 합리적일까요?

4. 생성자 체인의 이해

GreatWizard의 생성자에서 super()를 호출한 후 setMp(150)을 합니다.

  • Wizard의 생성자에서는 어떤 초기화가 이루어지나요?
  • 만약 Wizard 생성자가 명시적으로 정의되어 있지 않다면, 부모 클래스인 Person의 생성자는 어떻게 호출될까요?
  • Java의 생성자 체인 규칙을 다시 한번 상기하고, 현재 설계가 문제가 없는지 확인해보세요.

5. PlantUML 다이어그램과 실제 코드의 정합성

다이어그램에서는 Wizard의 일부 메서드가 패키지 접근(~)으로 표시되어 있습니다.

  • 실제 코드의 접근 제어자와 다이어그램 표현이 일치하는지 확인하셨나요?
  • 특히 heal() 메서드와 생성자들의 접근 제어 표현을 검토해보세요.

✨ 제안

  1. 데이터 일관성: 비슷한 목적의 메서드들(예: setHP vs setHp)이 다른 검증 로직을 가지는 이유를 문서화하거나, 일관된 정책으로 통일해보세요.

  2. 접근 제어 검토: 각 메서드의 현재 접근 수준이 정말 필요한 수준인지 다시 한번 확인하고, 필요하다면 적절히 조정해보세요.

  3. 게임 로직 설계: 몬스터의 공격력이 시간에 따라 약해지는 것이 의도된 설계인지, 다른 게임 개발자 입장에서도 이해할 수 있도록 고민해봅시다.


📝 종합 평가

상속의 기본 개념을 탄탄하게 이해하고 있으며, 실제 게임 도메인 모델을 통해 이를 구현했습니다. 코드 포매팅도 잘되어 있고 테스트도 작성했다는 점이 훌륭합니다. 위의 피드백들을 검토하며 더욱 견고한 설계로 개선한다면, 캡슐화와 상속이라는 객체지향의 핵심을 더욱 깊이 있게 이해할 수 있을 것입니다. 고생하셨습니다! 🎉

Walkthrough

Hero 클래스를 캡슐화하고 MaxHP 필드를 추가한다. SlimePoisonSlime, WizardGreatWizard 상속 계층을 신규 구현하며, 각각 JUnit 테스트를 추가한다. 전체 클래스 구조를 PlantUML 다이어그램으로 문서화하고 상속 학습 내용을 TIL 문서에 정리한다.

Changes

상속 계층 구현 및 문서화

Layer / File(s) Summary
Hero 캡슐화 및 MaxHP 추가
game/src/main/java/com/survivalcoding/Hero.java
name, HPprivate으로 전환하고 MaxHP 필드(기본값 100)를 추가한다. getName/setName, getMaxHP/setMaxHPpublic으로 추가하고 기존 attack()을 제거한다.
Slime/PoisonSlime 상속 계층 및 테스트
game/src/main/java/com/survivalcoding/Slime.java, game/src/main/java/com/survivalcoding/PoisonSlime.java, game/src/test/java/com/survivalcoding/PoisonSlimeTest.java
Slime을 신규 추가하여 attack(Hero)에서 HP를 10 감소시킨다. PoisonSlimeSlime을 상속하며 poisonCount 기반으로 추가 독 데미지(getHP()/5)를 적용한다. 테스트에서 두 번 공격 후 HP 72→50, poisonCount 4→3을 검증한다.
Wizard MP 힐 로직 변경 및 GreatWizard 추가, 테스트
game/src/main/java/com/survivalcoding/Wizard.java, game/src/main/java/com/survivalcoding/GreatWizard.java, game/src/test/java/com/survivalcoding/WizardTest.java, game/src/test/java/com/survivalcoding/GreatWizardTest.java
Wizardheal을 MP 검사 후 HP+20 고정 회복으로 변경한다. GreatWizard는 초기 MP 150으로 heal(MP-5, HP+25)을 오버라이드하고 superHeal(MP-50, HP를 MaxHP로 복구)을 추가한다. WizardTestGreatWizardTest에서 MP 소모 및 HP 변화를 검증한다.
PlantUML 클래스 다이어그램 추가
game/game.puml
com.survivalcoding 패키지 하위 8개 클래스(Cleric, Person, Wand, Hero, Wizard, GreatWizard, Slime, PoisonSlime)의 필드/메서드와 클래스 간 관계(구성, 상속, uses)를 PlantUML로 정의한다.
TIL 학습 문서 및 Exercise 주석 추가
TIL/sample/2026-06-16-상속.md, game/src/main/java/com/survivalcoding/Exercise.java
TIL 문서에 상속 개념 요약, PoisonSlime 실습 코드, plantUML 작업 경험을 기록한다. Exercise.java 주석에 연습문제 1 답과 is-a 매핑 정리를 추가한다.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
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.
Title check ❓ Inconclusive 제목 '26_06_16_13_김진용'은 상속 과제의 날짜와 학생명을 포함하지만, 주요 변경 사항을 구체적으로 설명하지 않아 변경 내용의 핵심을 파악하기 어렵습니다. 제목을 '상속(Inheritance) 구현: Slime, Wizard, GreatWizard 클래스 추가' 같이 주요 변경 사항을 명확히 반영하도록 개선하는 것을 권장합니다.
✅ 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: 4

🧹 Nitpick comments (3)
TIL/sample/2026-06-16-상속.md (2)

71-78: 💤 Low value

PlantUML 학습 내용 추가 제안.

"어려웠던 점" 섹션에 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

📥 Commits

Reviewing files that changed from the base of the PR and between e8f2d61 and edd71c7.

📒 Files selected for processing (11)
  • TIL/sample/2026-06-16-상속.md
  • game/game.puml
  • game/src/main/java/com/survivalcoding/Exercise.java
  • 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 +51 to +65
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
}

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

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.

Comment on lines +17 to +24
/*
26_06_16 연습문제 1
2,3,5
연습문제2
(1) 아이폰 -> Phone -> 기계
(2) BMW -> Car -> 고철
(3) 종이 한자 사전 -> Dictionary -> 폐지
*/

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

연습문제 주석: 문맥 명확화 필요.

라인 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.

Comment on lines +8 to +11
public Hero(String name, int HP) {
this.name = name;
this.HP = HP;
}

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

Hero의 HP/MaxHP 불변식이 보장되지 않습니다.

Line 8-11, Line 17-19, Line 38-40에서 값 검증 없이 대입되어 HP < 0, MaxHP <= 0, HP > MaxHP 상태가 가능합니다. Slime.attackGreatWizard.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;

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

선언되지 않은 변수 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.

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