-
Notifications
You must be signed in to change notification settings - Fork 18
260616_14_이인준 #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: student/14_이인준
Are you sure you want to change the base?
260616_14_이인준 #60
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| @startuml | ||
|
|
||
| class Hero { | ||
| - String name | ||
| - int hp | ||
| - int maxHp | ||
| + getName() : String | ||
| + setName(String) : void | ||
| + getHp() : int | ||
| + setHp(int) : void | ||
| + getMaxHp() : int | ||
| + setMaxHp(int) : void | ||
| } | ||
|
|
||
| class Cleric { | ||
| + int mp | ||
| + heal(Hero) : void | ||
| } | ||
|
|
||
| class Wizard { | ||
| - int hp | ||
| - int mp | ||
| - String name | ||
| - Wand wand | ||
| + getHp() : int | ||
| + setHp(int) : void | ||
| + getMp() : int | ||
| + setMp(int) : void | ||
| + getName() : String | ||
| + setName(String) : void | ||
| + getWand() : Wand | ||
| + setWand(Wand) : void | ||
| + heal(Hero) : void | ||
| } | ||
|
|
||
| class GreatWizard { | ||
| + heal(Hero) : void | ||
| + superHeal(Hero) : void | ||
| } | ||
|
|
||
| class Wand { | ||
| - String name | ||
| - double power | ||
| + getName() : String | ||
| + setName(String) : void | ||
| + getPower() : double | ||
| + setPower(double) : void | ||
| } | ||
|
|
||
| class Slime { | ||
| + String suffix | ||
| + int hp | ||
| + attack(Hero) : void | ||
| } | ||
|
Comment on lines
+50
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Slime 클래스의 실제 구현에서 suffix, hp 필드 가시성 확인
rg -A 15 'class Slime' game/src/main/java/com/survivalcoding/Slime.javaRepository: SurvivalCodingCampus/polytech_java2 Length of output: 388 Slime 클래스 필드 가시성이 다이어그램과 일치하지 않음. Diagram.puml의 51-52줄에서 suffix와 hp가 🤖 Prompt for AI Agents |
||
|
|
||
| class PoisonSlime { | ||
| - int poisonCount | ||
| + attack(Hero) : void | ||
| } | ||
|
|
||
| ' 상속 관계 | ||
| Hero <|-- Cleric | ||
| Wizard <|-- GreatWizard | ||
| Slime <|-- PoisonSlime | ||
|
|
||
| ' 연관 관계 | ||
| Wizard --> Wand : has | ||
| PoisonSlime ..> Hero : attacks | ||
| Slime ..> Hero : attacks | ||
| Cleric ..> Hero : heals | ||
| Wizard ..> Hero : heals | ||
| GreatWizard ..> Hero : superHeals | ||
|
|
||
| @enduml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| public class GreatWizard extends Wizard { | ||
|
|
||
| public GreatWizard() { | ||
| setMp(150); | ||
| } | ||
|
|
||
| @Override | ||
| void heal(Hero hero) { | ||
| if (getMp() < 5) { | ||
| System.out.println("Not enough MP"); | ||
| return; | ||
| } | ||
| hero.setHp(hero.getHp() + 25); | ||
| setMp(getMp() - 5); | ||
| System.out.println("Cast heal. Character HP: " + hero.getHp()); | ||
| } | ||
|
|
||
| void superHeal(Hero hero) { | ||
| if (getMp() < 50) { | ||
| System.out.println("Not enough MP"); | ||
| return; | ||
| } | ||
| hero.setHp(hero.getMaxHp()); // hp를 최대로 | ||
| setMp(getMp() - 50); | ||
| System.out.println("Cast super heal. Character HP: " + hero.getHp()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| public class Hero { | ||
| private String name; | ||
| private int hp; | ||
| private int maxHp = 100; | ||
|
|
||
| public String getName() { | ||
| return name; | ||
|
|
@@ -19,4 +20,12 @@ public int getHp() { | |
| public void setHp(int hp) { | ||
| this.hp = hp; | ||
| } | ||
| } | ||
|
|
||
| public int getMaxHp() { | ||
| return maxHp; | ||
| } | ||
|
|
||
| public void setMaxHp(int maxHp) { | ||
| this.maxHp = maxHp; | ||
| } | ||
|
Comment on lines
+24
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
제안 수정안 public void setHp(int hp) {
- this.hp = hp;
+ if (hp < 0) {
+ hp = 0;
+ }
+ if (hp > this.maxHp) {
+ hp = this.maxHp;
+ }
+ this.hp = hp;
}
public void setMaxHp(int maxHp) {
- this.maxHp = maxHp;
+ if (maxHp < 0) {
+ throw new IllegalArgumentException("maxHp must be over 0.");
+ }
+ this.maxHp = maxHp;
+ if (this.hp > maxHp) {
+ this.hp = maxHp;
+ }
}🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||
| package com.survivalcoding; | ||||||
|
|
||||||
| public class PoisonSlime extends Slime { | ||||||
| private int poisonCount = 5; | ||||||
|
|
||||||
| public PoisonSlime(String suffix) { | ||||||
| super(suffix); | ||||||
| this.suffix = suffix; | ||||||
| } | ||||||
|
Comment on lines
+6
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생성자에서 중복 할당 제거 필요 Line 8에서 🐛 제안된 수정 public PoisonSlime(String suffix) {
super(suffix);
- this.suffix = suffix;
}🤖 Prompt for AI Agents |
||||||
|
|
||||||
| @Override | ||||||
| void attack(Hero hero) { | ||||||
| super.attack(hero); | ||||||
|
|
||||||
| if (poisonCount != 0) { | ||||||
| System.out.println("Poison attack!"); | ||||||
|
|
||||||
| int poisonDamage = hero.getHp() / 5; | ||||||
| hero.setHp(hero.getHp() - poisonDamage); | ||||||
| System.out.println(poisonDamage + "point damage"); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 출력 문자열의 띄어쓰기 누락
🐛 제안된 수정- System.out.println(poisonDamage + "point damage");
+ System.out.println(poisonDamage + " point damage");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| poisonCount--; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| // 01 | ||
| // 1. student is person (o) | ||
| // 2. Engine is car (x) | ||
| // 3. Child is father (x) | ||
| // 4. Sushi is Food (o) | ||
| // 5. Man is SuperMan (x) | ||
|
|
||
|
|
||
| // 02 | ||
| // 1. i_phone17 --|> Phone --|> Device | ||
| // 2. Avante --|> Car --|> Vehicle | ||
| // 3. En/Kr Dictionary --|> Dictionary --|> Book | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||
| package com.survivalcoding; | ||||||
|
|
||||||
| public class Slime { | ||||||
| String suffix; | ||||||
| int hp; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사용되지 않는 필드 제거 또는 초기화 필요
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| public Slime(String suffix) { | ||||||
| this.suffix = suffix; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| void attack(Hero hero) { | ||||||
| System.out.println("Slime " + suffix + "attacked"); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 출력 문자열의 띄어쓰기 누락
🐛 제안된 수정- System.out.println("Slime " + suffix + "attacked");
+ System.out.println("Slime " + suffix + " attacked");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| System.out.println("10 point damage"); | ||||||
|
|
||||||
| hero.setHp(hero.getHp() - 10); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hero HP가 음수가 될 수 있는 공통 경계 조건 미검증 두 파일 모두에서 Hero의 HP를 감소시킬 때 하한선(0) 검증이 없어 HP가 음수가 될 수 있습니다. 이는 게임 상태의 무결성을 해칠 수 있으므로 모든 데미지 적용 지점에서 HP를 최소 0으로 제한해야 합니다.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,4 +76,19 @@ void setWand_normal() { | |
|
|
||
| assertEquals(wand, wizard.getWand()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("heal prints mana insufficient message when mp is under 10") | ||
| void heal_prints_insufficient_message_when_mp_under_10() { | ||
|
|
||
| Wizard wizard = new Wizard(); | ||
| wizard.setMp(5); | ||
| Hero hero = new Hero(); | ||
| hero.setHp(50); | ||
|
|
||
| wizard.heal(hero); | ||
|
|
||
| assertEquals(50, hero.getHp()); // hp 변화 없음 | ||
| assertEquals(5, wizard.getMp()); // mp 변화 없음 | ||
| } | ||
|
Comment on lines
+81
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트 이름/설명과 실제 검증이 불일치합니다. 현재 테스트는 출력 메시지가 아니라 HP/MP 상태만 검증합니다. 🤖 Prompt for AI Agents |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: SurvivalCodingCampus/polytech_java2
Length of output: 1602
🏁 Script executed:
Repository: SurvivalCodingCampus/polytech_java2
Length of output: 1290
Cleric 필드 가시성 및 캡슐화 패턴 불일치 수정 필요.
다이어그램(Line 16)에서
+ int mp로 표시되어 있으나, 실제 Cleric.java 구현에서는 default access(제한자 없음)로 선언되어 있습니다. 더 중요하게는, Hero와 Wizard 클래스는private필드와 getter/setter 메서드를 통해 캡슐화를 구현하고 있으므로, Cleric도 이 패턴을 따르도록 수정해야 합니다. 다이어그램의 mp, hp, name을 모두 private(-)로 변경하고, 해당 접근자 메서드를 추가하거나 기존 구현과 동기화하세요.🤖 Prompt for AI Agents