20260616_19_윤우상#56
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
코드 리뷰 및 피드백안녕하세요! 상속과 UML 개념을 담은 좋은 과제 제출입니다. 전반적으로 기본기가 잘 다져져 있으나, 몇 가지 생각해볼 점들을 제시합니다. 칭찬할 점 ✨
생각해볼 점 💭1. 메서드 오버라이드의 의도 확인
`@Override`
public void attack() {
super.attack();
}질문: 이 메서드가 단순히 부모의 2. 부모-자식 클래스 간 메서드 구현 비교
질문: 3. Cleric 클래스의 설계 검토현재 질문: 4. Hero 클래스의 attack() 메서드현재 public void attack() {
hp -= 1;
System.out.println("공격했다");
}질문: 공격할 때마다 HP가 1씩 깎인다는 것이 맞는 설계일까요? 일반적인 게임 설계 관점에서 "공격하는 주체"가 피해를 입는 것이 합리적일까요? 혹은 매개변수를 통해 "누구에게" 공격하는지 명시하는 것이 더 나을까요? 5. 매직 넘버(Magic Number) 검토여러 클래스에서 하드코딩된 숫자들(예: 질문: 이러한 상수들(예: 제언
이번 과제는 상속의 기본을 잘 이해하고 있음을 보여줍니다. 위의 질문들을 통해 더욱 견고한 설계를 만들 수 있을 것 같습니다! 🎯 Walkthrough
Changes게임 캐릭터 상속 계층 구현
Sequence Diagram(s)sequenceDiagram
rect rgba(70, 130, 180, 0.5)
Note over PoisonSlime,Hero: PoisonSlime 공격 흐름
end
participant PoisonSlime
participant Slime
participant Hero
PoisonSlime->>Slime: super.attack(hero)
Slime->>Hero: setHP(getHP() - slimeAttackPoint)
alt poisonCount > 0
PoisonSlime->>Hero: setHP(getHP() * 4 / 5)
PoisonSlime->>PoisonSlime: poisonCount--
else poisonCount == 0
PoisonSlime->>PoisonSlime: 독 소모 완료 메시지 출력
end
sequenceDiagram
rect rgba(60, 179, 113, 0.5)
Note over GreatWizard,Hero: GreatWizard heal / superHeal 흐름
end
participant GreatWizard
participant Hero
alt heal: getMP() >= 5
GreatWizard->>Hero: setHP(getHP() + recoverPoint)
GreatWizard->>GreatWizard: setMP(getMP() - 5)
else heal: getMP() < 5
GreatWizard->>GreatWizard: "마나가 부족합니다." 출력
end
alt superHeal: getMP() >= 50
GreatWizard->>Hero: setHP(getMaxHP())
GreatWizard->>GreatWizard: 슈퍼 힐 메시지 출력
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ 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: 8
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
game/src/test/java/com/survivalcoding/ClericTest.java (1)
33-47:⚠️ Potential issue | 🟠 Major | ⚡ Quick win경계값 테스트가
clamp정책과 충돌합니다.현재는 범위 이탈 입력에서 예외를 기대하지만,
Cleric구현은 범위 내 보정(clamp)으로 바뀌었습니다. 예외 검증 대신 보정된 값 검증으로 바꿔야 합니다.수정 제안 diff
- // 최대, 최소 값을 지키지 않는 경우 생성이 안되는지 검증 - assertAll("최대값, 최소값을 지키지 않았을 경우 확인", - () -> assertThrows(IllegalArgumentException.class, () -> { - Cleric overflowHPCase = new Cleric(testName, overflowHP); - }, "HP 최대값 초과 예외처리가 발생하지 않음"), - () -> assertThrows(IllegalArgumentException.class, () -> { - Cleric overflowMPCase = new Cleric(testName, testHP, overflowMP); - }, "MP 최대값 초과 예외처리가 발생하지 않음"), - () -> assertThrows(IllegalArgumentException.class, () -> { - Cleric underflowHPCase = new Cleric(testName, underflowHP); - }, "HP 음수, 0 입력 예외처리가 발생하지 않음"), - () -> assertThrows(IllegalArgumentException.class, () -> { - Cleric underflowMPCase = new Cleric(testName, testHP, underflowMP); - }, "MP 음수 입력 예외처리가 발생하지 않음") - ); + // clamp 정책 검증: 범위를 벗어난 값은 경계값으로 보정 + Cleric overflowHPCase = new Cleric(testName, overflowHP); + Cleric overflowMPCase = new Cleric(testName, testHP, overflowMP); + Cleric underflowHPCase = new Cleric(testName, underflowHP); + Cleric underflowMPCase = new Cleric(testName, testHP, underflowMP); + + assertAll("최대값/최소값 보정 확인", + () -> assertEquals(Cleric.maxHP, overflowHPCase.getHP()), + () -> assertEquals(Cleric.maxMP, overflowMPCase.getMP()), + () -> assertEquals(0, underflowHPCase.getHP()), + () -> assertEquals(0, underflowMPCase.getMP()) + );🤖 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/ClericTest.java` around lines 33 - 47, The test in the ClericTest class is verifying that IllegalArgumentException is thrown for out-of-range HP and MP values, but the actual Cleric implementation uses value clamping instead of throwing exceptions. Replace the four assertThrows blocks (for overflowHPCase, overflowMPCase, underflowHPCase, and underflowMPCase) with positive assertions that verify the Cleric object is created successfully with the values properly clamped to their valid ranges. For each case, construct a Cleric instance and assert that its HP or MP values equal the expected clamped boundaries rather than expecting an exception to be thrown.
🤖 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 17-31: The Hero class UML diagram is missing the name field that
corresponds to the existing getName() and setName() methods, and it also lacks
the slip() method mentioned in the PR description. Add a private String field
named name to the Hero class attributes section, and add the public void slip()
method to the operations section to synchronize the UML specification with the
actual code implementation.
In `@game/src/main/java/com/survivalcoding/Cleric.java`:
- Around line 50-59: The code uses Math.clamp in the setHP and setMP methods of
the Cleric class (and also in Slime.java at line 26), but Math.clamp is only
available in Java 21 and above. To fix this, do one of the following: (1) Update
game/build.gradle by adding sourceCompatibility = '21' and targetCompatibility =
'21' to explicitly require Java 21 as the minimum version, or (2) if Java 20 or
lower must be supported, create a custom clamp utility method that implements
the same logic (constraining a value between a minimum and maximum) and replace
all Math.clamp calls in Cleric.java's setHP and setMP methods and in Slime.java
with calls to this custom method.
In `@game/src/main/java/com/survivalcoding/GreatWizard.java`:
- Around line 55-58: The superHeal method in GreatWizard checks if sufficient MP
is available but does not consume the MP after successfully healing the hero,
and it lacks an else branch to handle insufficient MP. After setting the hero's
HP to maximum within the if block where MP >= 50 is confirmed, you must also
deduct 50 MP from the caster (using a setMP method or similar). Additionally,
add an else branch that prints "마나가 부족합니다." to handle the case when MP is less
than 50.
In `@game/src/main/java/com/survivalcoding/Hero.java`:
- Around line 43-45: The HP validation invariant is being bypassed through
multiple code paths. At the anchor location in the setHP method
(game/src/main/java/com/survivalcoding/Hero.java, lines 43-45), add a lower
bound check using Math.max to ensure hp is never set below 0, complementing the
existing upper bound check with Math.min. At the sibling locations (lines 51-53,
55-58, and 69-81), replace all direct assignments to the hp field with calls to
the setHP setter method to ensure validation is applied consistently.
Additionally, in the setMaxHP method around lines 51-53, after reducing maxHP,
recalculate hp by calling setHP with the current hp value to re-clamp it in case
it now exceeds the new maximum.
In `@game/src/main/java/com/survivalcoding/Slime.java`:
- Around line 33-35: The setMaxHP() method sets the new maximum HP but does not
recalibrate the current hp value when the new maxHP is lower than the existing
hp, potentially leaving the object in an invalid state where hp exceeds maxHP.
After setting this.maxHP in the setMaxHP() method, add a line to ensure that the
current hp is capped to not exceed the new maxHP value by reassigning this.hp to
the minimum of its current value and the new maxHP.
- Line 26: The Math.clamp method used in the Slime.java file (in the assignment
to this.hp) is only available in Java 21 and later, but the build.gradle does
not specify a Java version requirement. Either update build.gradle to set
sourceCompatibility and targetCompatibility to Java 21 or higher, or replace the
Math.clamp(hp, 0, maxHP) call with an equivalent implementation compatible with
older Java versions such as Math.max(Math.min(hp, maxHP), 0) to ensure the code
compiles in your target environment.
In `@game/src/test/java/com/survivalcoding/GreatWizardTest.java`:
- Around line 45-56: The heal and superHeal test methods only verify HP recovery
but do not validate that MP is properly consumed during the healing action,
which allows MP deduction bugs to go undetected. For both the heal method test
(lines 45-56) and superHeal method test (lines 83-94), add assertions that
verify the MP was correctly deducted (comparing MP before the heal call to MP
after minus the expected consumption amount). Additionally, add separate test
cases for each healing method to verify the behavior when the caster has
insufficient MP to perform the heal, ensuring both the normal path MP
consumption and the MP insufficiency edge case are properly tested.
In `@TIL/2026-06-16-inheritance.md`:
- Around line 89-92: The method signature for isFlying() in the SuperHero class
has an incorrect return type notation. The current signature shows "+void
boolean isFlying()" with both void and boolean listed as return types, which is
invalid UML notation. Remove the "void" keyword from the isFlying() method
signature so it reads "+boolean isFlying()" to correctly indicate that the
method returns a boolean value.
---
Outside diff comments:
In `@game/src/test/java/com/survivalcoding/ClericTest.java`:
- Around line 33-47: The test in the ClericTest class is verifying that
IllegalArgumentException is thrown for out-of-range HP and MP values, but the
actual Cleric implementation uses value clamping instead of throwing exceptions.
Replace the four assertThrows blocks (for overflowHPCase, overflowMPCase,
underflowHPCase, and underflowMPCase) with positive assertions that verify the
Cleric object is created successfully with the values properly clamped to their
valid ranges. For each case, construct a Cleric instance and assert that its HP
or MP values equal the expected clamped boundaries rather than expecting an
exception to be thrown.
🪄 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: 4bb53d2b-3740-412d-af3a-2d2d27b27874
⛔ Files ignored due to path filters (1)
image/ClassDiagram.pngis excluded by!**/*.png
📒 Files selected for processing (17)
TIL/2026-06-16-inheritance.mdgame/game.pumlgame/src/main/java/com/survivalcoding/Cleric.javagame/src/main/java/com/survivalcoding/GreatWizard.javagame/src/main/java/com/survivalcoding/Hero.javagame/src/main/java/com/survivalcoding/Person.javagame/src/main/java/com/survivalcoding/PoisonSlime.javagame/src/main/java/com/survivalcoding/Slime.javagame/src/main/java/com/survivalcoding/SuperHero.javagame/src/main/java/com/survivalcoding/Wand.javagame/src/main/java/com/survivalcoding/Wizard.javagame/src/test/java/com/survivalcoding/ClericTest.javagame/src/test/java/com/survivalcoding/GreatWizardTest.javagame/src/test/java/com/survivalcoding/HeroTest.javagame/src/test/java/com/survivalcoding/PoisonSlimeTest.javagame/src/test/java/com/survivalcoding/SlimeTest.javagame/src/test/java/com/survivalcoding/WandTest.java
💤 Files with no reviewable changes (2)
- game/src/main/java/com/survivalcoding/Wand.java
- game/src/main/java/com/survivalcoding/Person.java
| public void setHP(int hp) { | ||
| this.hp = Math.clamp(hp, 0, maxHP); | ||
| } | ||
|
|
||
| public int getMP() { | ||
| return mp; | ||
| } | ||
|
|
||
| public void setMP(int mp) { | ||
| this.mp = Math.clamp(mp, 0, maxMP); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Potential Java toolchain files =="
fd -HI 'pom.xml|build.gradle|build.gradle.kts|gradle.properties|settings.gradle|mvnw|.tool-versions|.java-version|.sdkmanrc' | sort
echo
echo "== Java version declarations =="
TOOLCHAIN_FILES="$(fd -HI 'pom.xml|build.gradle|build.gradle.kts|gradle.properties|settings.gradle|.tool-versions|.java-version|.sdkmanrc' || true)"
if [ -n "${TOOLCHAIN_FILES}" ]; then
rg -n --no-heading 'sourceCompatibility|targetCompatibility|toolchain|languageVersion|maven.compiler.source|maven.compiler.target|<release>|java.version|--release' ${TOOLCHAIN_FILES} || true
else
echo "No toolchain declaration files found."
fi
echo
echo "== Math.clamp usage sites =="
rg -n --no-heading 'Math\.clamp\s*\('Repository: SurvivalCodingCampus/polytech_java2
Length of output: 541
🏁 Script executed:
#!/bin/bash
echo "=== game/build.gradle ==="
cat game/build.gradle
echo -e "\n=== root build.gradle ==="
cat build.gradle
echo -e "\n=== settings.gradle ==="
cat settings.gradleRepository: SurvivalCodingCampus/polytech_java2
Length of output: 931
🏁 Script executed:
#!/bin/bash
echo "=== Checking for gradle.properties ==="
if [ -f gradle.properties ]; then
cat gradle.properties
else
echo "No gradle.properties found"
fi
echo -e "\n=== Checking for JAVA_HOME or java version in system ==="
which java && java -version 2>&1 || echo "Java not available in sandbox"
echo -e "\n=== Double-checking all Math.clamp usages with context ==="
rg -B 2 -A 2 'Math\.clamp\s*\(' game/src/Repository: SurvivalCodingCampus/polytech_java2
Length of output: 1412
Math.clamp 사용을 위해 Java 21 이상으로 빌드 버전을 명시해야 합니다.
현재 build.gradle에 sourceCompatibility 또는 targetCompatibility가 선언되어 있지 않습니다. Math.clamp는 Java 21 이상에서만 사용 가능하므로, 다음 중 하나를 수행하세요:
game/build.gradle에 명시적으로 Java 버전을 선언:sourceCompatibility = '21'및targetCompatibility = '21'추가- 또는 Java 20 이하를 지원해야 하면 별도의 clamp 구현으로 대체
현재 Math.clamp 사용 위치
game/src/main/java/com/survivalcoding/Slime.java:26
game/src/main/java/com/survivalcoding/Cleric.java:51
game/src/main/java/com/survivalcoding/Cleric.java:59
🤖 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/Cleric.java` around lines 50 - 59, The
code uses Math.clamp in the setHP and setMP methods of the Cleric class (and
also in Slime.java at line 26), but Math.clamp is only available in Java 21 and
above. To fix this, do one of the following: (1) Update game/build.gradle by
adding sourceCompatibility = '21' and targetCompatibility = '21' to explicitly
require Java 21 as the minimum version, or (2) if Java 20 or lower must be
supported, create a custom clamp utility method that implements the same logic
(constraining a value between a minimum and maximum) and replace all Math.clamp
calls in Cleric.java's setHP and setMP methods and in Slime.java with calls to
this custom method.
| public void setHP(int hp) { | ||
| this.hp = hp; | ||
| this.hp = Math.min(hp, maxHP); | ||
| } |
There was a problem hiding this comment.
HP/이름 검증 불변식이 여러 경로에서 우회됩니다.
Line 44는 하한(0) 보정이 없고, Line 56-57/70/80은 setter를 거치지 않아 검증·클램프가 깨집니다. Line 52도 maxHP 축소 시 현재 hp를 재보정하지 않아 hp > maxHP 상태가 남습니다.
수정 예시
public void setHP(int hp) {
- this.hp = Math.min(hp, maxHP);
+ this.hp = Math.max(0, Math.min(hp, maxHP));
}
public void setMaxHP(int maxHP) {
this.maxHP = Math.max(maxHP, 0);
+ this.hp = Math.min(this.hp, this.maxHP);
}
public Hero(String name, int hp) {
- this.name = name;
- this.hp = hp;
+ setName(name);
+ setHP(hp);
}
public void attack() {
- hp -= 1;
+ setHP(this.hp - 1);
System.out.println("공격했다");
}
public final void slip() {
- hp -= 5;
+ setHP(this.hp - 5);
System.out.println("미끄러졌다!");
}Also applies to: 51-53, 55-58, 69-81
🤖 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 43 - 45, The HP
validation invariant is being bypassed through multiple code paths. At the
anchor location in the setHP method
(game/src/main/java/com/survivalcoding/Hero.java, lines 43-45), add a lower
bound check using Math.max to ensure hp is never set below 0, complementing the
existing upper bound check with Math.min. At the sibling locations (lines 51-53,
55-58, and 69-81), replace all direct assignments to the hp field with calls to
the setHP setter method to ensure validation is applied consistently.
Additionally, in the setMaxHP method around lines 51-53, after reducing maxHP,
recalculate hp by calling setHP with the current hp value to re-clamp it in case
it now exceeds the new maximum.
|
|
||
| public void setHP(int hp) { | ||
| // 체력이 음수가 될 경우 0 으로, maxHP를 초과할 경우 maxHP로 보정 | ||
| this.hp = Math.clamp(hp, 0, maxHP); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "[1] Java 타깃/툴체인 선언 확인"
for f in $(fd -HI 'pom.xml|build.gradle|build.gradle.kts|gradle.properties|.tool-versions|.java-version|.sdkmanrc'); do
echo "=== $f ==="
rg -n "maven-compiler-plugin|<release>|sourceCompatibility|targetCompatibility|toolchain|languageVersion|java\\.version" "$f" || true
done
echo
echo "[2] Math.clamp 사용 위치 확인"
rg -n "Math\\.clamp\\(" --type javaRepository: SurvivalCodingCampus/polytech_java2
Length of output: 496
🏁 Script executed:
cat -n game/build.gradleRepository: SurvivalCodingCampus/polytech_java2
Length of output: 570
🏁 Script executed:
cat -n build.gradleRepository: SurvivalCodingCampus/polytech_java2
Length of output: 570
🏁 Script executed:
rg -i "java.*version|javaTarget|release" --type gradle -A 2 -B 2Repository: SurvivalCodingCampus/polytech_java2
Length of output: 61
🏁 Script executed:
find .github/workflows -name '*.yml' -o -name '*.yaml' 2>/dev/null | head -20Repository: SurvivalCodingCampus/polytech_java2
Length of output: 61
🏁 Script executed:
cat -n gradle.properties 2>/dev/null || echo "No gradle.properties found"Repository: SurvivalCodingCampus/polytech_java2
Length of output: 106
🏁 Script executed:
rg -i "sourceCompatibility|targetCompatibility" . --type gradle --type propertiesRepository: SurvivalCodingCampus/polytech_java2
Length of output: 114
🏁 Script executed:
fd -HI 'README|readme' | head -5 | xargs cat 2>/dev/null || echo "No README found"Repository: SurvivalCodingCampus/polytech_java2
Length of output: 61
🏁 Script executed:
cat -n game/src/main/java/com/survivalcoding/Slime.java | head -35Repository: SurvivalCodingCampus/polytech_java2
Length of output: 1019
🏁 Script executed:
rg -i "java.*21|jdk.*21" . 2>/dev/null || echo "No Java 21 references found"Repository: SurvivalCodingCampus/polytech_java2
Length of output: 107
Java 21 이상의 버전 설정이 필수입니다.
Math.clamp는 Java 21에서 추가된 메서드로, 현재 build.gradle에 Java 버전이 명시되어 있지 않습니다. 컴파일 환경에 따라 Java 21 미만에서는 컴파일 실패가 발생할 수 있습니다. build.gradle에 sourceCompatibility 또는 targetCompatibility를 Java 21 이상으로 명시하거나, Java 21 미만을 지원해야 한다면 Math.max(Math.min(hp, maxHP), 0) 등으로 변경해야 합니다.
🤖 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/Slime.java` at line 26, The Math.clamp
method used in the Slime.java file (in the assignment to this.hp) is only
available in Java 21 and later, but the build.gradle does not specify a Java
version requirement. Either update build.gradle to set sourceCompatibility and
targetCompatibility to Java 21 or higher, or replace the Math.clamp(hp, 0,
maxHP) call with an equivalent implementation compatible with older Java
versions such as Math.max(Math.min(hp, maxHP), 0) to ensure the code compiles in
your target environment.
| public void setMaxHP(int maxHP) { | ||
| this.maxHP = Math.max(maxHP, 0); | ||
| } |
There was a problem hiding this comment.
setMaxHP() 호출 후 현재 HP 재보정이 필요합니다.
Line 34에서 maxHP를 낮춰도 현재 hp가 그대로라 hp > maxHP 상태가 남을 수 있습니다.
수정 예시
public void setMaxHP(int maxHP) {
this.maxHP = Math.max(maxHP, 0);
+ this.hp = Math.min(this.hp, this.maxHP);
}📝 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 void setMaxHP(int maxHP) { | |
| this.maxHP = Math.max(maxHP, 0); | |
| } | |
| public void setMaxHP(int maxHP) { | |
| this.maxHP = Math.max(maxHP, 0); | |
| this.hp = Math.min(this.hp, this.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/Slime.java` around lines 33 - 35, The
setMaxHP() method sets the new maximum HP but does not recalibrate the current
hp value when the new maxHP is lower than the existing hp, potentially leaving
the object in an invalid state where hp exceeds maxHP. After setting this.maxHP
in the setMaxHP() method, add a line to ensure that the current hp is capped to
not exceed the new maxHP value by reassigning this.hp to the minimum of its
current value and the new maxHP.
| @DisplayName("heal 정상 작동 여부 확인") | ||
| void heal() { | ||
| // Given | ||
| // testGreatWizard는 setUp에서 준비됨 | ||
| testHero.setHP(testHero.getMaxHP() - GreatWizard.recoverPoint); | ||
|
|
||
| // when | ||
| testGreatWizard.heal(testHero); | ||
|
|
||
| // then | ||
| assertEquals(testHero.getMaxHP(), testHero.getHP()); | ||
| } |
There was a problem hiding this comment.
heal/superHeal 테스트가 MP 소모 계약을 검증하지 않습니다.
현재 테스트는 HP 회복만 확인해서, MP 차감 누락 회귀를 통과시킬 수 있습니다. 각 테스트에 “호출 전 MP - 소모량” 검증과 MP 부족 분기 케이스를 추가해 주세요.
보강 예시 diff
void heal() {
// Given
// testGreatWizard는 setUp에서 준비됨
testHero.setHP(testHero.getMaxHP() - GreatWizard.recoverPoint);
+ int beforeMP = testGreatWizard.getMP();
// when
testGreatWizard.heal(testHero);
// then
assertEquals(testHero.getMaxHP(), testHero.getHP());
+ assertEquals(beforeMP - 5, testGreatWizard.getMP());
}
@@
void superHeal() {
// given
// testGreatWizard는 setUp에서 준비됨
testHero.setHP(superHealTestHP);
+ int beforeMP = testGreatWizard.getMP();
// when
testGreatWizard.superHeal(testHero);
// then
assertEquals(testHero.getMaxHP(), testHero.getHP());
+ assertEquals(beforeMP - 50, testGreatWizard.getMP());
}Also applies to: 83-94
🤖 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/GreatWizardTest.java` around lines 45 -
56, The heal and superHeal test methods only verify HP recovery but do not
validate that MP is properly consumed during the healing action, which allows MP
deduction bugs to go undetected. For both the heal method test (lines 45-56) and
superHeal method test (lines 83-94), add assertions that verify the MP was
correctly deducted (comparing MP before the heal call to MP after minus the
expected consumption amount). Additionally, add separate test cases for each
healing method to verify the behavior when the caster has insufficient MP to
perform the heal, ensuring both the normal path MP consumption and the MP
insufficiency edge case are properly tested.
| class SuperHero extends Hero { | ||
| +void setFlying(boolean Flying) | ||
| +void boolean isFlying() | ||
| } |
There was a problem hiding this comment.
UML 예시 메서드 시그니처 표기를 수정해 주세요.
Line 91의 +void boolean isFlying()는 반환형 표기가 잘못되었습니다. +boolean isFlying()로 고쳐야 예시가 올바른 형태가 됩니다.
🤖 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/2026-06-16-inheritance.md` around lines 89 - 92, The method signature for
isFlying() in the SuperHero class has an incorrect return type notation. The
current signature shows "+void boolean isFlying()" with both void and boolean
listed as return types, which is invalid UML notation. Remove the "void" keyword
from the isFlying() method signature so it reads "+boolean isFlying()" to
correctly indicate that the method returns a boolean value.
20260616_19_윤우상
📝 과제 정보
📋 체크리스트
📷 실행 결과 (또는 테스트 결과)
❓질문 및 어려웠던 점
🔄 자체 평가 & 회고