-
Notifications
You must be signed in to change notification settings - Fork 18
260616_17_서인호 #59
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
Open
cornaill008
wants to merge
3
commits into
SurvivalCodingCampus:student/17_서인호
Choose a base branch
from
cornaill008:master
base: student/17_서인호
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
260616_17_서인호 #59
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
day02-instance-class/src/main/java/com/survivalcoding/GreatWizard.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| public class GreatWizard extends Wizard { | ||
| public GreatWizard() { | ||
| setMp(150); | ||
| } | ||
|
|
||
| @Override | ||
| public void heal(Hero hero) { | ||
| if (getMp() < 5) { | ||
| System.out.println("마나가 부족합니다"); | ||
| return; | ||
| } | ||
| hero.setHp(hero.getHp() + 25); | ||
| setMp(getMp() - 5); | ||
| System.out.println("힐을 시전했습니다. 대상 HP: " + hero.getHp()); | ||
| } | ||
|
|
||
| public void superHeal(Hero hero) { | ||
| if (getMp() < 50) { | ||
| System.out.println("마나가 부족합니다"); | ||
| return; | ||
| } | ||
|
|
||
| hero.setHp(100); | ||
| setMp(getMp() - 50); | ||
| System.out.println("슈퍼 힐을 시전했습니다. 대상 HP: " + hero.getHp()); | ||
| } | ||
| } | ||
|
|
24 changes: 24 additions & 0 deletions
24
day02-instance-class/src/main/java/com/survivalcoding/PoisonSlime.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| public class PoisonSlime extends Slime { | ||
| private int poisonCount = 5; | ||
|
|
||
| public PoisonSlime(String suffix) { | ||
| super(suffix); | ||
| } | ||
|
|
||
| @Override | ||
| void attack(Hero hero) { | ||
| super.attack(hero); | ||
|
|
||
| if (poisonCount > 0) { | ||
| System.out.println("추가로, 독 포자를 살포했다!"); | ||
|
|
||
| int poisonDamage = hero.getHp() / 5; | ||
| hero.setHp(hero.getHp() - poisonDamage); | ||
| System.out.println(poisonDamage + "포인트 데미지"); | ||
|
|
||
| poisonCount--; | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
day02-instance-class/src/main/java/com/survivalcoding/Slime.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| public class Slime { | ||
|
|
||
| final String suffix; | ||
| int hp; | ||
|
|
||
| public Slime(String suffix) { | ||
| this.suffix = suffix; | ||
| this.hp = 50; | ||
| } | ||
|
|
||
| // 생성자, getter, setter 작성 | ||
|
|
||
| void attack(Hero hero) { | ||
| System.out.println("슬라임 " + suffix + "이/가 공격했다"); | ||
| System.out.println("10의 데미지"); | ||
|
|
||
| hero.setHp(hero.getHp() - 10); | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
day02-instance-class/src/main/java/com/survivalcoding/Wizard.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,69 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| public class Wizard { | ||
|
|
||
| private int hp; | ||
| private int mp = 100; | ||
| private String name; | ||
| private Wand wand; | ||
|
|
||
| public int getHp() { | ||
| return hp; | ||
| } | ||
|
|
||
| public void setHp(int hp) { | ||
| if (hp < 0) { | ||
| this.hp = 0; | ||
| return; | ||
| } | ||
| this.hp = hp; | ||
| } | ||
|
|
||
| public int getMp() { | ||
| return mp; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| if (name == null || name.length() < 3) { | ||
| throw new IllegalArgumentException("마법사의 이름은 null일 수 없고 3문자 이상이어야 합니다"); | ||
| } | ||
| this.name = name; | ||
| } | ||
|
|
||
| public void setMp(int mp) { | ||
| if (mp < 0) { | ||
| throw new IllegalArgumentException("마법사의 MP는 0 이상이어야 합니다"); | ||
| } | ||
| this.mp = mp; | ||
| } | ||
|
|
||
| public void setWand(Wand wand) { | ||
| if (wand == null) { | ||
| throw new IllegalArgumentException("마법사의 지팡이는 null일수 없습니다."); | ||
| } | ||
| this.wand = wand; | ||
| } | ||
|
|
||
| public void heal(Hero hero) { | ||
| if (mp < 10) { | ||
| System.out.println("마나가 부족합니다"); | ||
| return; | ||
| } | ||
|
|
||
| hero.setHp(hero.getHp() + 20); | ||
| mp -= 10; | ||
| System.out.println("힐을 시전했습니다. 대상 HP: " + hero.getHp()); | ||
| } | ||
|
|
||
|
|
||
| public void fireball(Hero hero) { | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
28 changes: 28 additions & 0 deletions
28
day02-instance-class/src/main/java/com/survivalcoding/연습문제_1.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.survivalcoding; | ||
|
|
||
| public class 연습문제_1 { | ||
| /* 1. Person Student (O) | ||
| 2. car Engine (X) | ||
| 3. Father Child (X) | ||
| 4. Food Sushi (O) | ||
| 5. SuperMan Man (X) | ||
|
|
||
|
|
||
|
|
||
| */ | ||
| } | ||
|
|
||
|
|
||
| /* 연습문제_2 | ||
| 1 2 3 | ||
| 부모 클래스 ElectronicDevice Vehicle Book | ||
|
|
||
|
|
||
| Phone Car Dictionary | ||
|
|
||
|
|
||
|
|
||
| 자식 클래스 I-Phone Bus EnglishDictionary | ||
|
|
||
|
|
||
| */ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
공통 원인: 전투/치유 API의 대상 파라미터 null 경계 검증이 빠져 있습니다.
day02-instance-class/src/main/java/com/survivalcoding/Wizard.java#L51-L60:heal(Hero hero)시작 지점에 null 검증을 추가하세요.day02-instance-class/src/main/java/com/survivalcoding/GreatWizard.java#L9-L17:heal(Hero hero)에 동일한 null 검증(또는 공통 헬퍼)을 적용하세요.day02-instance-class/src/main/java/com/survivalcoding/GreatWizard.java#L19-L27:superHeal(Hero hero)에도 동일한 검증을 적용하세요.day02-instance-class/src/main/java/com/survivalcoding/Slime.java#L15-L20:attack(Hero hero)베이스 메서드에서 null 검증을 추가해 하위 클래스 호출 경로까지 보호하세요.📍 Affects 3 files
day02-instance-class/src/main/java/com/survivalcoding/Wizard.java#L51-L60(this comment)day02-instance-class/src/main/java/com/survivalcoding/GreatWizard.java#L9-L17day02-instance-class/src/main/java/com/survivalcoding/GreatWizard.java#L19-L27day02-instance-class/src/main/java/com/survivalcoding/Slime.java#L15-L20🤖 Prompt for AI Agents