-
Notifications
You must be signed in to change notification settings - Fork 20
250701_19_최아인 #160
base: student/19_최아인
Are you sure you want to change the base?
250701_19_최아인 #160
Conversation
Summary by CodeRabbit새 기능
문서
버그 수정
테스트
기타
Walkthrough이번 변경 사항은 다양한 자바 기초 학습 노트, UML 다이어그램, 실습 예제, 그리고 테스트 코드 파일을 대거 추가하고, 일부 기존 파일(예: Person.java)을 삭제하는 내용입니다. 주요 변경점은 자바 상속, 추상 클래스, 인터페이스, 컬렉션, 제네릭, Enum, 객체 동등성, 복사, 테스트 코드, 그리고 여러 도메인 모델의 클래스 다이어그램 정의 등입니다. Changes
Sequence Diagram(s)예시 1: Asset 계층 구조 및 인터페이스 활용sequenceDiagram
participant Main as AssetMain
participant Book
participant Computer
participant Water
participant Thing
Main->>Book: Book 인스턴스 생성
Main->>Computer: Computer 인스턴스 생성
Main->>Water: Water 인스턴스 생성
Main->>Thing: assets 리스트에 추가(Thing 인터페이스로 업캐스팅)
예시 2: Monster 계층 구조 및 메소드 오버라이드sequenceDiagram
participant Goblin
participant WalkingMonster
participant Monster
Goblin->>WalkingMonster: run() 호출(슈퍼)
WalkingMonster->>Monster: run() 오버라이딩
Goblin->>Goblin: run() 추가 동작(출력)
Goblin->>Goblin: attack() 오버라이딩(출력)
예시 3: StrongBox 사용 시나리오sequenceDiagram
participant User
participant StrongBox
User->>StrongBox: put(item)
loop get() 호출 반복
User->>StrongBox: get()
alt 사용 제한 도달
StrongBox-->>User: item 반환
else
StrongBox-->>User: null 반환
end
end
예시 4: Book equals/hashCode 및 컬렉션 동작sequenceDiagram
participant User
participant Book
participant List
participant Set
User->>Book: b1, b2 인스턴스 생성(동일 속성)
User->>List: b1 추가
User->>List: b2 제거(동등성 비교)
User->>Set: b1 추가
User->>Set: b2 제거(동등성 비교)
예시 5: Cleric.pray() 및 selfAid() 동작sequenceDiagram
participant Test
participant Cleric
Test->>Cleric: pray(sec)
Cleric-->>Test: MP 회복량 반환
Test->>Cleric: selfAid()
Cleric-->>Test: HP/MP 상태 변경
(위 다이어그램들은 주요 변경점과 클래스 간 상호작용의 예시를 단순화하여 표현하였습니다.) ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 42
🧹 Nitpick comments (43)
.gitignore (1)
44-44:.idea/전체 무시는 기존 규칙과 중복될 수 있습니다.이미 8~13라인에서
.idea/*개별 파일·디렉터리를 지정하고 있어, 상위 디렉터리 전체를 추가로 무시하면 중복 규칙이 생깁니다. 기능적으로 문제는 없지만 불필요한 중복을 줄이려면 둘 중 하나만 유지하는 편이 깔끔합니다.src/main/java/com/survivalcoding/Person.java (2)
24-27: 나이 계산 로직이 부정확할 수 있습니다.현재 구현은 생일을 고려하지 않고 단순히 연도 차이만 계산합니다. 생일이 지나지 않았다면 실제 나이보다 1살 많게 계산될 수 있습니다.
더 정확한 나이 계산이 필요하다면 생년월일을 모두 저장하거나, 현재 구현이 의도된 것이라면 메서드 문서화를 추가하는 것을 고려해보세요:
+/** + * 출생년도를 기준으로 한 나이를 반환합니다. + * 생월일은 고려하지 않습니다. + * @return 현재 연도 - 출생년도 + */ public int getAge() { int yy = cal.get(Calendar.YEAR); return yy - birthYear; }
29-30: 불필요한 빈 줄을 제거하세요.클래스 끝에 불필요한 빈 줄이 있습니다.
- }src/test/java/com/survivalcoding/PersonTest.java (1)
8-16: 테스트 커버리지를 확장하세요.현재 하나의 테스트 케이스만 있습니다. 다양한 시나리오를 테스트하여 코드의 견고성을 확인하는 것이 좋습니다.
추가 테스트 케이스를 고려해보세요:
@Test @DisplayName("이름을 정확히 반환한다") void getName() { Person person = new Person("김철수", 1990); assertEquals("김철수", person.getName()); } @Test @DisplayName("출생년도를 정확히 반환한다") void getBirthYear() { Person person = new Person("김철수", 1990); assertEquals(1990, person.getBirthYear()); } @Test @DisplayName("잘못된 입력에 대해 예외를 발생시킨다") void invalidConstructorParameters() { assertThrows(IllegalArgumentException.class, () -> new Person(null, 2000)); assertThrows(IllegalArgumentException.class, () -> new Person("", 2000)); assertThrows(IllegalArgumentException.class, () -> new Person("홍길동", -1)); }src/main/java/Asset/Patent.java (1)
3-9: 학습 목적으로 Patent 클래스에 특화된 속성 추가를 고려해보세요.현재
Patent클래스는 최소한의 구현만 되어 있습니다. 실제 특허를 나타내는 클래스라면 특허 번호, 만료일, 발명자 등의 속성을 추가하는 것을 고려해볼 수 있습니다.src/main/java/Asset/Computer.java (2)
7-9: 생성자에서 makerName 초기화를 고려하세요.현재 생성자는 부모 클래스의 필드만 초기화하고
makerName은 초기화하지 않습니다. 객체 생성 시 완전한 상태로 초기화하거나, 기본값 설정을 고려해보세요.다음 중 하나의 방법을 선택할 수 있습니다:
방법 1: 생성자 매개변수 추가
- public Computer(String name, int price, String color) { + public Computer(String name, int price, String color, String makerName) { super(name, price, color); + this.makerName = makerName; }방법 2: 기본값 설정
public Computer(String name, int price, String color) { super(name, price, color); + this.makerName = "Unknown"; }
15-17: setter 메서드에 유효성 검증을 추가하세요.
setMakerName메서드에서 null 또는 빈 문자열에 대한 검증을 추가하는 것이 좋습니다.public void setMakerName(String makerName) { + if (makerName == null || makerName.trim().isEmpty()) { + throw new IllegalArgumentException("제조사명은 null이거나 빈 값일 수 없습니다."); + } this.makerName = makerName; }src/main/java/Asset/AssetMain.java (2)
9-10: 하드코딩된 값을 상수나 의미있는 값으로 변경하세요.객체 생성 시 "aa", "bb"와 같은 하드코딩된 값 대신 의미있는 값이나 상수를 사용하는 것이 좋습니다.
- Book book = new Book("aa", 10, "bb"); - Computer computer = new Computer("aa", 10, "bb"); + Book book = new Book("Java Programming", 25000, "Blue"); + Computer computer = new Computer("Laptop", 1500000, "Silver");
14-18: 생성된 객체들을 활용하는 코드를 추가하세요.현재 객체들을 생성하고 리스트에 추가만 하고 있습니다. 학습 목적으로 다형성을 보여주는 코드를 추가하면 더 유용할 것입니다.
List<Thing> assets = new ArrayList<>(); assets.add(book); assets.add(computer); assets.add(water); + + // 다형성 예시 + for (Thing asset : assets) { + System.out.println("Weight: " + asset.getWeight()); + }src/main/java/Asset/Asset.java (1)
21-23: price 필드에 유효성 검증을 고려하세요.가격은 일반적으로 음수가 될 수 없으므로, setter에서 유효성 검증을 추가하는 것을 고려해보세요.
public void setPrice(int price) { + if (price < 0) { + throw new IllegalArgumentException("가격은 0보다 작을 수 없습니다."); + } this.price = price; }src/main/java/Asset/Asset.puml (2)
4-8: Asset 클래스에 생성자 정보를 추가하세요.다이어그램에서 Asset 클래스의 생성자 정보가 누락되어 있습니다. 완전한 문서화를 위해 추가하는 것이 좋습니다.
abstract class Asset { String name int price String color + + Asset(String name, int price, String color) }
26-31: Computer 클래스에 생성자 정보를 추가하세요.Computer 클래스의 생성자 정보도 다이어그램에 포함하면 더 완전한 문서가 될 것입니다.
class Computer { String makerName + Computer(String name, int price, String color) String getMakerName() void setMakerName(String makerName) }TIL/topics/java_basic/2025.06.10 JAVA기초.md (2)
4-5: 내용 보완 필요객체지향이 필요한 이유에 대한 설명이 불완전합니다. 성능 향상보다는 코드의 재사용성, 유지보수성, 모듈화 등의 장점을 중심으로 설명하면 더 정확할 것 같습니다.
14-14: this 키워드 설명 개선 필요"this."에 대한 설명이 명확하지 않습니다. "현재 객체의 인스턴스를 참조하는 키워드로, 인스턴스 변수와 매개변수가 같은 이름일 때 구분하기 위해 사용한다"는 식으로 정확히 설명하면 좋겠습니다.
TIL/topics/java_basic/2025.06.17 .md (1)
39-42: 내용 정리 필요오버로드에 대한 설명이 불완전하고 문맥이 명확하지 않습니다. "메서드 오버로딩은 같은 이름의 메서드를 매개변수의 타입이나 개수를 다르게 하여 여러 개 정의하는 것"이라고 명확히 설명하면 좋겠습니다.
src/main/java/com/survivalcoding/Main.java (1)
5-9: 사용하지 않는 변수들을 정리해주세요.선언된 변수들(
ii,isMarried,d,f,name)이 사용되지 않고 있습니다. 학습 목적이라면 주석으로 설명을 추가하거나, 실제 사용하지 않는다면 제거하는 것이 좋겠습니다.- int ii = 10; - boolean isMarried = true; - double d = 5.0; - float f = 2.5f; - String name = ""; + // 기본 데이터 타입 예제 + // int ii = 10; + // boolean isMarried = true; + // double d = 5.0; + // float f = 2.5f; + // String name = "";src/main/java/com/survivalcoding/Character.java (1)
7-15: main 메서드의 코드를 정리하거나 의미 있는 구현을 추가하세요.주석 처리된 코드와 빈 attack 구현이 있습니다. 이는 데모 목적이라면 더 명확한 예시를 제공하거나, 불필요하다면 제거하는 것이 좋겠습니다.
다음 중 하나를 선택하세요:
옵션 1: 의미 있는 구현 추가
Character character = new Character() { @Override public void attack(Slime slime) { - + System.out.println("공격을 시전합니다!"); } }; + // 데모 실행 + character.attack(new Slime());옵션 2: main 메서드 제거
- public static void main(String[] args) { -// Character c = new Character(); - Character character = new Character() { - @Override - public void attack(Slime slime) { - - } - }; - }src/test/java/com/survivalcoding/HeroTest.java (2)
10-23: 테스트 메서드 이름을 더 구체적으로 변경하세요.현재
heroTest라는 이름은 테스트 내용을 명확히 표현하지 못합니다. 여러 테스트 케이스로 분리하거나 더 구체적인 이름을 사용하세요.다음과 같이 개선할 수 있습니다:
- @Test - void heroTest() { + @Test + void testHeroCreationAndHpValidation() { Hero hero = new Hero("영웅", 100); assertEquals(100, hero.getHp()); + } + + @Test + void testHpSetterWithValidValues() { + Hero hero = new Hero("영웅", 100); hero.setHp(0); assertEquals(0, hero.getHp()); hero.setHp(1); assertEquals(1, hero.getHp()); + } + @Test + void testHpSetterThrowsExceptionForNegativeValues() { + Hero hero = new Hero("영웅", 100); assertThrows(IllegalArgumentException.class, () -> { hero.setHp(-100); }); }
7-25: 추가 테스트 케이스를 고려해보세요.현재 HP 관련 테스트만 있지만, Hero 클래스의 다른 기능들도 테스트해볼 수 있습니다.
다음과 같은 추가 테스트를 고려해보세요:
@Test void testHeroNameValidation() { Hero hero = new Hero("영웅", 100); assertEquals("영웅", hero.getName()); } @Test void testHeroAttackMethod() { Hero hero = new Hero("영웅", 100); Slime slime = new Slime(); // attack 메서드 동작 확인 assertDoesNotThrow(() -> hero.attack(slime)); } @Test void testHeroRunMethod() { Hero hero = new Hero("영웅", 100); // run 메서드 동작 확인 assertDoesNotThrow(() -> hero.run()); }src/main/java/com/survivalcoding/Sword.java (1)
16-22: main 메소드를 별도 클래스로 분리 권장프로덕션 클래스에 테스트용 main 메소드가 포함되어 있습니다. 테스트 코드는 별도의 테스트 클래스나 demo 클래스로 분리하는 것이 좋습니다.
별도의 SwordDemo 클래스를 생성하거나 JUnit 테스트 클래스로 이동하는 것을 고려해보세요.
// SwordDemo.java 또는 테스트 클래스에서 public class SwordDemo { public static void main(String[] args) { Sword sword = new Sword("엑스칼리버"); Sword sword2 = new Sword(); System.out.println(sword.getName()); System.out.println(sword.getDamage()); } }src/test/java/com/survivalcoding/KinokoTest.java (1)
5-17: 주석 처리된 테스트 코드 활성화 또는 제거 필요테스트 메소드가 주석 처리되어 있습니다. 테스트를 완성하여 활성화하거나 불필요하다면 제거해야 합니다.
테스트를 활성화하려면 다음과 같이 수정하고 필요한 import 문을 추가하세요:
+import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; +import static org.junit.jupiter.api.Assertions.assertEquals; + - /*@Test //옵션 설명이 같이 나온다? + @Test @DisplayName("heal을 하면 hp를 10 회복해야 한다") void heal() { // given(준비) final Wizard wizard = new Wizard("마법사", 100); final Hero hero = new Hero("히어로", 10); // when(실행) wizard.heal(hero); // then(검증) assertEquals(20, hero.hp); - }*/ + }이 테스트 코드를 완성하고 활성화할까요?
src/main/java/com/survivalcoding/Kinoko.java (1)
12-15: 매개변수 shadowing 해결 필요setHP() 메소드의 매개변수
hp가 인스턴스 필드hp와 같은 이름을 사용하고 있습니다.this.hp를 사용하여 명확하게 구분하고 있지만, 혼란을 피하기 위해 매개변수 이름을 다르게 하는 것이 좋습니다.- void setHP(int hp) { - this.hp = hp; + void setHP(int newHp) { + this.hp = newHp; System.out.println("hp 를 회복"); }또한 메소드명을 Java 명명 규칙에 맞게
setHp()로 변경하는 것을 고려해보세요.src/main/java/inheritance/PoisonSlime.java (1)
6-9: 생성자 구현 개선 필요생성자가 super()를 호출하고 있지만, 생성자 본문이 비어있습니다. 코드 스타일을 일관되게 유지하기 위해 개선이 필요합니다.
public PoisonSlime(String name, int hp) { - super(name, hp); }src/test/java/com/survivalcoding/WandTest.java (1)
20-23: 주석 처리된 코드를 정리하세요.tearDown 메서드에서 주석 처리된 코드를 제거하는 것이 좋습니다.
@AfterEach void tearDown() { -// System.out.println("끝날 때"); }src/main/java/inheritance/Hero.java (1)
32-32: 불필요한 주석을 제거하세요.getter, setter, 생성자가 이미 모두 구현되어 있으므로 이 주석은 오해를 불러일으킬 수 있습니다.
- // getter, setter, 생성자 생략src/main/java/com/survivalcoding/SuperHero.java (1)
3-3: 사용하지 않는 import 제거 필요
java.awt.image.Kernelimport가 코드에서 사용되지 않고 있습니다.-import java.awt.image.Kernel;src/test/java/com/survivalcoding/PoisonSlimeTest.java (1)
19-33: 테스트 메소드명 개선 제안테스트 메소드명이
attack,attack2,attack3로 되어 있어 각 테스트의 목적을 파악하기 어렵습니다.@DisplayName은 있지만 메소드명도 의미를 명확히 하는 것이 좋습니다.다음과 같이 메소드명을 개선해보세요:
@Test @DisplayName("독 공격 횟수 테스트") -void attack() { +void shouldDecrementPoisonCountAfterAttacks() {src/main/java/com/survivalcoding/PoisonSlime.java (1)
21-33: 독 데미지 계산 로직 승인 및 개선 제안독 데미지를 hero hp의 1/5로 계산하는 로직이 흥미롭습니다. 다만 정수 나눗셈으로 인해 소수점이 버려집니다 (예: hp가 7일 때 데미지는 1).
더 정확한 계산을 원한다면 다음과 같이 개선할 수 있습니다:
-int damage = hero.getHp() / 5; +int damage = Math.max(1, hero.getHp() / 5); // 최소 1의 데미지 보장TIL/topics/java_basic/2025.06.16 JAVA 클래스.md (1)
1-76: TIL 문서 구조 개선 제안Java 클래스에 대한 다양한 개념들이 포함되어 있지만, 내용이 다소 산만하게 정리되어 있습니다. 학습 효과를 높이기 위해 다음과 같이 구조화를 고려해보세요:
- 메모리 구조 (기본형 vs 참조형)
- 생성자 (기본 생성자, 오버로딩, this 키워드)
- static 키워드 (클래스 변수, 메모리 특성)
- 코드 예제 (실습 내용)
추가로 일부 오타나 불완전한 문장들을 정리하면 더 좋을 것 같습니다:
- "참조형이다? 기본형이다? 참조형이다." → 명확한 설명으로 정리
- "요렇게", "여기???에" → 정확한 표현으로 수정
src/main/java/com/survivalcoding/StrongBox.java (1)
4-12: 주석 처리된 코드를 제거하세요.사용하지 않는 주석 처리된 코드는 코드베이스를 어지럽히고 가독성을 해칩니다. 버전 관리 시스템이 있기 때문에 이전 버전을 확인할 수 있으므로 주석 처리된 코드는 삭제하는 것이 좋습니다.
src/test/java/com/survivalcoding/ClericTest.java (1)
12-17: 테스트 설정 중복을 제거하세요.BeforeEach 메서드에서 공통 설정을 처리하여 코드 중복을 줄이는 것을 고려해보세요.
+ private Cleric cleric; + + @BeforeEach + void setUp() { + cleric = new Cleric(); + }Also applies to: 26-32, 41-47
TIL/topics/java_basic/2025.06 4주.md (1)
12-13: 빈 섹션에 내용을 추가하세요.오버라이드와 구체화/일반화 관계에 대한 설명이 부족합니다. 학습 목적으로 더 자세한 설명을 추가하는 것이 좋겠습니다.
Also applies to: 15-17
src/main/java/com/survivalcoding/Slime.java (2)
52-52: 주석 처리된 잘못된 캐스팅 코드를 제거하세요.Hero로 캐스팅하는 코드는 컴파일 오류를 발생시키므로 완전히 제거하는 것이 좋습니다.
-// Slime slime1 = (Hero) monster;
54-59: 데모 코드를 별도 클래스로 분리하세요.main 메서드의 캐스팅 예제 코드는 학습 목적이라면 별도의 데모 클래스로 분리하는 것이 좋겠습니다.
src/main/java/com/survivalcoding/Cleric.java (2)
6-7: 정적 상수는 대문자와 언더스코어를 사용해야 합니다Java 명명 규칙에 따라 정적 상수는 UPPER_SNAKE_CASE를 사용해야 합니다.
- static final int maxHp = 50; - static final int maxMp = 10; + static final int MAX_HP = 50; + static final int MAX_MP = 10;관련된 모든 참조도 함께 업데이트해야 합니다.
13-29: 생성자 매개변수 명명 규칙 수정 필요Java 매개변수는 소문자로 시작하는 camelCase를 사용해야 합니다.
- Cleric(String name, int HP, int MP) { + Cleric(String name, int hp, int mp) { this.name = name; - this.hp = HP; - this.mp = MP; + this.hp = hp; + this.mp = mp; } - Cleric(String name, int HP) { + Cleric(String name, int hp) { this.name = name; - this.hp = HP; - this.mp = maxMp; + this.hp = hp; + this.mp = MAX_MP; } Cleric(String name) { this.name = name; - this.hp = maxHp; - this.mp = maxMp; + this.hp = MAX_HP; + this.mp = MAX_MP; }src/main/java/com/survivalcoding/Hero.java (2)
47-49: 오타 수정 필요에러 메시지에 오타가 있습니다.
- if (name.length() >= 8) { - throw new IllegalArgumentException("이름이 너무 긺"); - } + if (name.length() >= 8) { + throw new IllegalArgumentException("이름이 너무 긴"); + }
77-77: 테스트 코드는 별도의 테스트 클래스로 이동 권장main 메서드에서 의도적으로 예외를 발생시키는 테스트 코드가 있습니다. 이런 테스트는 JUnit 테스트로 작성하는 것이 좋습니다.
HeroTest 클래스에 음수 HP 검증 테스트를 추가하시겠습니까?
src/main/java/com/survivalcoding/Wizard.java (2)
27-29: 미구현 메서드에 TODO 주석 추가fireball 메서드가 구현되지 않았습니다.
public void fireball(Slime slime) { - + // TODO: fireball 구현 필요 + throw new UnsupportedOperationException("Not implemented yet"); }fireball 메서드 구현을 도와드릴까요?
52-75: getter/setter 메서드 명명 규칙 통일 필요Java 명명 규칙에 따라 메서드명은 camelCase를 사용해야 합니다.
- public int getHP () { + public int getHp() { return hp; } - public void setHP (int hp) { + public void setHp(int hp) { if (hp < 0) { this.hp = 0; } else { this.hp = hp; } } - public int getMP () { + public int getMp() { return mp; } - public void setMP (int mp) { + public void setMp(int mp) { if (mp < 0) { throw new IllegalArgumentException("MP는 0이상 이어야 한다."); } this.mp = mp; }src/main/java/com/survivalcoding/2025.07.01과제.puml (3)
69-69: 빈 인터페이스에 대한 설명 필요
IEnhanceable인터페이스가 메서드 없이 정의되어 있습니다. 마커 인터페이스로 사용되는 것이라면 주석으로 용도를 명시하거나, 필요한 메서드를 추가해주세요.
115-117: 패키지 접두사 사용 검토 필요
Heroes.EnhancedHero와 같이 패키지명을 포함한 참조는 일반적이지 않습니다. PlantUML에서는 클래스명만으로도 충분히 참조가 가능합니다.다음과 같이 수정하는 것을 제안합니다:
-Heroes.EnhancedHero ..|> ISelfRecoverable #FF6B35 -Heroes.EnhancedHero ..|> IAttackable #28A745 -Heroes.EnhancedHero ..|> IEnhanceable #0019f4 +EnhancedHero ..|> ISelfRecoverable #FF6B35 +EnhancedHero ..|> IAttackable #28A745 +EnhancedHero ..|> IEnhanceable #0019f4
1-139: 전반적으로 잘 설계된 아키텍처입니다!객체지향 원칙이 잘 적용된 설계입니다. PR 목표에서 언급된 enum 학습과 관련하여,
Faction이나 히어로 타입 같은 고정된 값들을 enum으로 정의하는 것도 고려해보세요.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (57)
.gitignore(1 hunks)README.md(1 hunks)TIL/topics/java_basic/2025.06 4주.md(1 hunks)TIL/topics/java_basic/2025.06.10 JAVA기초.md(1 hunks)TIL/topics/java_basic/2025.06.16 JAVA 클래스.md(1 hunks)TIL/topics/java_basic/2025.06.17 .md(1 hunks)TIL/topics/java_basic/2025.07 1주.md(1 hunks)TIL/topics/java_basic/용어정리.md(1 hunks)src/main/java/Asset/Asset.java(1 hunks)src/main/java/Asset/Asset.puml(1 hunks)src/main/java/Asset/AssetMain.java(1 hunks)src/main/java/Asset/Book.java(1 hunks)src/main/java/Asset/Computer.java(1 hunks)src/main/java/Asset/IntangibleAsset.java(1 hunks)src/main/java/Asset/Patent.java(1 hunks)src/main/java/Asset/TangibleAsset.java(1 hunks)src/main/java/Asset/Thing.java(1 hunks)src/main/java/Monster/FlyingMonster.java(1 hunks)src/main/java/Monster/Goblin.java(1 hunks)src/main/java/Monster/Monster.java(1 hunks)src/main/java/Monster/WalkingMonster.java(1 hunks)src/main/java/Monster/WarWolf.java(1 hunks)src/main/java/com/survivalcoding/2025.07.01과제.puml(1 hunks)src/main/java/com/survivalcoding/Character.java(1 hunks)src/main/java/com/survivalcoding/Cleric.java(1 hunks)src/main/java/com/survivalcoding/Hero.java(1 hunks)src/main/java/com/survivalcoding/KeyType.java(1 hunks)src/main/java/com/survivalcoding/Kinoko.java(1 hunks)src/main/java/com/survivalcoding/Main.java(1 hunks)src/main/java/com/survivalcoding/Person.java(1 hunks)src/main/java/com/survivalcoding/PoisonSlime.java(1 hunks)src/main/java/com/survivalcoding/Slime.java(1 hunks)src/main/java/com/survivalcoding/StrongBox.java(1 hunks)src/main/java/com/survivalcoding/SuperHero.java(1 hunks)src/main/java/com/survivalcoding/Sword.java(1 hunks)src/main/java/com/survivalcoding/Wand.java(1 hunks)src/main/java/com/survivalcoding/Wizard.java(1 hunks)src/main/java/com/survivalcoding/assignments_01_instance/exam01/Person.java(0 hunks)src/main/java/com/survivalcoding/game.puml(1 hunks)src/main/java/com/survivalcoding/list/ListMain.java(1 hunks)src/main/java/generic/AuthState.java(1 hunks)src/main/java/generic/EnumMain.java(1 hunks)src/main/java/generic/Pocket.java(1 hunks)src/main/java/inheritance/GreatWizard.java(1 hunks)src/main/java/inheritance/Hero.java(1 hunks)src/main/java/inheritance/PoisonSlime.java(1 hunks)src/main/java/inheritance/Slime.java(1 hunks)src/main/java/inheritance/SuperHero.java(1 hunks)src/main/java/inheritance/Wizard.java(1 hunks)src/main/java/inheritance/inheritance.puml(1 hunks)src/test/java/com/survivalcoding/ClericTest.java(1 hunks)src/test/java/com/survivalcoding/HeroTest.java(1 hunks)src/test/java/com/survivalcoding/KinokoTest.java(1 hunks)src/test/java/com/survivalcoding/PersonTest.java(1 hunks)src/test/java/com/survivalcoding/PoisonSlimeTest.java(1 hunks)src/test/java/com/survivalcoding/WandTest.java(1 hunks)src/test/java/inheritance/PoisonSlimeTest.java(1 hunks)
💤 Files with no reviewable changes (1)
- src/main/java/com/survivalcoding/assignments_01_instance/exam01/Person.java
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
README.md (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
TIL/topics/java_basic/2025.07 1주.md (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
TIL/topics/java_basic/2025.06.10 JAVA기초.md (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
TIL/topics/java_basic/용어정리.md (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
TIL/topics/java_basic/2025.06.16 JAVA 클래스.md (1)
Learnt from: rycbar1214
PR: SurvivalCodingCampus/polytech_java_study#107
File: src/main/java/com/survivalcoding/assignments_01_instance/exam01/PoisonSlime.java:0-0
Timestamp: 2025-06-23T06:06:39.556Z
Learning: Java에서 자식 클래스 생성자는 반드시 부모 클래스의 생성자를 호출해야 하며, 부모 클래스에 기본 생성자가 없고 매개변수가 있는 생성자만 있다면 명시적으로 super()를 호출해야 한다.
src/main/java/inheritance/Wizard.java (1)
Learnt from: sezondo
PR: SurvivalCodingCampus/polytech_java_study#92
File: src/test/java/com/survivalcoding/WizardTest.java:21-33
Timestamp: 2025-06-17T07:25:21.221Z
Learning: In Java game programming, MP (Magic Points) value of 0 is a valid state representing a wizard who has used all their magic, so validation should only reject negative values, not zero.
TIL/topics/java_basic/2025.06 4주.md (1)
Learnt from: rycbar1214
PR: SurvivalCodingCampus/polytech_java_study#107
File: src/main/java/com/survivalcoding/assignments_01_instance/exam01/PoisonSlime.java:0-0
Timestamp: 2025-06-23T06:06:39.556Z
Learning: Java에서 자식 클래스 생성자는 반드시 부모 클래스의 생성자를 호출해야 하며, 부모 클래스에 기본 생성자가 없고 매개변수가 있는 생성자만 있다면 명시적으로 super()를 호출해야 한다.
TIL/topics/java_basic/2025.06.17 .md (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
src/main/java/com/survivalcoding/Wizard.java (1)
Learnt from: sezondo
PR: SurvivalCodingCampus/polytech_java_study#92
File: src/test/java/com/survivalcoding/WizardTest.java:21-33
Timestamp: 2025-06-17T07:25:21.221Z
Learning: In Java game programming, MP (Magic Points) value of 0 is a valid state representing a wizard who has used all their magic, so validation should only reject negative values, not zero.
🧬 Code Graph Analysis (15)
src/main/java/Monster/FlyingMonster.java (1)
src/main/java/Monster/Monster.java (1)
Monster(3-11)
src/main/java/Asset/Patent.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/main/java/Asset/TangibleAsset.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/main/java/Asset/Thing.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/main/java/Asset/Book.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/main/java/Monster/WalkingMonster.java (1)
src/main/java/Monster/Monster.java (1)
Monster(3-11)
src/main/java/Asset/IntangibleAsset.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/main/java/Monster/Goblin.java (1)
src/main/java/Monster/Monster.java (1)
Monster(3-11)
src/main/java/Monster/WarWolf.java (1)
src/main/java/Monster/Monster.java (1)
Monster(3-11)
src/main/java/Asset/Computer.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/main/java/generic/Pocket.java (2)
src/main/java/com/survivalcoding/Cleric.java (1)
Cleric(5-80)src/main/java/inheritance/Wizard.java (1)
Wizard(3-16)
src/main/java/Asset/AssetMain.java (1)
src/main/java/Asset/Asset.java (1)
Asset(3-38)
src/test/java/com/survivalcoding/PoisonSlimeTest.java (1)
src/main/java/com/survivalcoding/PoisonSlime.java (1)
PoisonSlime(3-35)
src/test/java/inheritance/PoisonSlimeTest.java (1)
src/main/java/inheritance/PoisonSlime.java (1)
PoisonSlime(3-25)
src/main/java/com/survivalcoding/Slime.java (1)
src/main/java/Monster/Monster.java (1)
Monster(3-11)
🪛 markdownlint-cli2 (0.17.2)
TIL/topics/java_basic/2025.06.10 JAVA기초.md
4-4: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
5-5: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
8-8: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
9-9: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
10-10: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
14-14: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
TIL/topics/java_basic/용어정리.md
7-7: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
8-8: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
9-9: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
10-10: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
11-11: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
12-12: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
13-13: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
14-14: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
15-15: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
16-16: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
17-17: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
TIL/topics/java_basic/2025.06.17 .md
5-5: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
7-7: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
9-9: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
11-11: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
13-13: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
15-15: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
19-19: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
20-20: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
21-21: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
22-22: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
23-23: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
24-24: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
25-25: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
26-26: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
27-27: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
28-28: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
29-29: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
30-30: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
31-31: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
35-35: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
36-36: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
37-37: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
63-63: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
🔇 Additional comments (45)
.gitignore (1)
45-46: AI 툴 산출물 무시 👍
.claude/,CLAUDE.md추가는 환경별 산출물을 깔끔히 제외하기 위해 적절합니다. 별다른 문제 없어 보입니다.README.md (1)
1-3: README에 프로젝트 개요·사용법을 추가해 주세요간단한 자기소개만으로는 저장소 목적, 디렉터리 구조, 빌드·테스트 방법 등이 파악되지 않습니다. 2-3문단 정도로 과제 제출 흐름과 실행 방법을 설명하면 학습자·리뷰어 모두 이해가 빨라집니다.
[ suggest_nitpick ]src/main/java/com/survivalcoding/list/ListMain.java (1)
5-19: 컬렉션은 인터페이스 타입으로 선언하고 다이아몬드 연산자를 사용하세요구현체(ArrayList)에 직접 의존하기보다
List<String>으로 선언하면 유연성이 높습니다. 또한new ArrayList<>()로 타입을 생략해 가독성을 개선할 수 있습니다.final은 재할당만 막고 요소 변경은 허용하니 의도에 맞는지 확인해 보세요.
[ suggest_optional_refactor ]-import java.util.ArrayList; +import java.util.ArrayList; +import java.util.List; @@ - final ArrayList<String> names = new ArrayList<>(); + final List<String> names = new ArrayList<>();TIL/topics/java_basic/용어정리.md (1)
6-17: 마크다운 리스트 들여쓰기(MD007) 경고
-기호 앞에 불필요한 공백이 있어 lint 오류가 발생합니다. 모든 항목을 동일한 열에 맞추면 해결됩니다.
[ suggest_nitpick ]src/main/java/Asset/Thing.java (1)
3-9: 인터페이스 설계가 잘 되어 있습니다.
Thing인터페이스가 간결하고 명확하게 정의되어 있으며, 무게 관련 메서드들이 적절히 선언되어 있습니다.src/main/java/Asset/IntangibleAsset.java (1)
3-9: 추상 클래스 구조가 적절합니다.
IntangibleAsset추상 클래스가 올바르게 구현되어 있으며, 무형 자산들을 위한 기본 클래스 역할을 잘 수행하고 있습니다.src/main/java/Asset/Book.java (1)
7-17: 생성자와 메서드 구현이 올바릅니다.생성자에서 부모 클래스를 적절히 호출하고, isbn에 대한 getter/setter 메서드가 올바르게 구현되어 있습니다.
src/main/java/Asset/TangibleAsset.java (1)
3-18: 추상 클래스와 인터페이스 구현이 잘 설계되어 있습니다.
TangibleAsset클래스가Asset을 상속받고Thing인터페이스를 올바르게 구현하고 있습니다.weight필드를protected로 선언한 것도 적절하며, 인터페이스의 메서드들이 올바르게 구현되어 있습니다.src/main/java/Asset/Asset.java (1)
3-38: 잘 구현된 추상 클래스입니다.
Asset클래스가 Java의 모범 사례를 잘 따르고 있습니다:
- private 필드와 public 접근자를 통한 적절한 캡슐화
- 모든 필드를 초기화하는 생성자
- 표준 JavaBean 규약 준수
src/main/java/Asset/Asset.puml (1)
1-56: 우수한 클래스 다이어그램입니다.PlantUML을 사용한 클래스 다이어그램이 잘 작성되었습니다:
- 상속 관계와 인터페이스 구현 관계가 명확하게 표현됨
- 실제 Java 코드와 일치하는 구조
- 코드 이해와 설계 문서화에 도움이 됨
src/main/java/com/survivalcoding/KeyType.java (1)
3-21: 잘 구현된 열거형입니다KeyType 열거형이 올바르게 구현되었습니다. 각 키 타입별로 적절한 사용 제한 값이 설정되어 있고, 생성자와 getter 메서드도 잘 구현되었습니다. 코드 스타일과 명명 규칙도 Java 표준을 따르고 있습니다.
TIL/topics/java_basic/2025.07 1주.md (1)
1-27: 학습 노트 내용이 적절합니다Java 기본 개념들(다형성, 인터페이스, 제네릭, 열거형, 이너클래스)에 대한 간결한 정리가 잘 되어 있습니다. 학습 목적으로는 적절한 수준의 내용입니다.
src/main/java/generic/AuthState.java (1)
3-8: 인증 상태 enum이 잘 정의되었습니다.인증 상태를 나타내는 enum 값들이 의미가 명확하고 네이밍 컨벤션을 잘 따르고 있습니다. 일반적인 인증 시나리오를 모두 포함하고 있어 실용적입니다.
src/main/java/Monster/WalkingMonster.java (1)
3-9: 상속 구조가 올바르게 구현되었습니다.
WalkingMonster가Monster추상 클래스를 적절히 확장하고run()메서드를 구현했습니다. 여전히 추상 클래스로 남겨두어 하위 클래스에서attack()메서드를 구현하도록 하는 설계가 좋습니다.src/main/java/Monster/FlyingMonster.java (1)
3-10: 비행 몬스터 클래스가 일관성 있게 구현되었습니다.
FlyingMonster가WalkingMonster와 일관된 패턴으로 구현되어 몬스터 계층 구조의 일관성을 유지하고 있습니다. 각 몬스터 타입에 특화된run()동작을 제공하는 설계가 적절합니다.src/main/java/Monster/Goblin.java (1)
3-16: 메서드 오버라이딩이 올바르게 구현되었습니다.
Goblin클래스가WalkingMonster를 적절히 확장하고 필요한 추상 메서드들을 구현했습니다. 특히run()메서드에서super.run()을 먼저 호출한 후 고블린만의 동작을 추가하는 패턴이 좋습니다.src/main/java/com/survivalcoding/Main.java (1)
13-16: Kinoko 객체 사용이 적절합니다.
Kinoko인스턴스를 생성하고 HP를 설정하는 코드가 올바르게 구현되었습니다. 한국어 메시지 출력도 의도에 맞게 작성되어 있습니다.src/main/java/Monster/WarWolf.java (1)
3-16: 잘 구현된 몬스터 클래스입니다.WalkingMonster를 상속받아 attack()과 run() 메서드를 적절히 오버라이드했습니다. 특히 run() 메서드에서 super.run()을 먼저 호출하여 부모 클래스의 동작을 보존한 후 자체 동작을 추가한 것이 좋습니다.
src/main/java/com/survivalcoding/Sword.java (1)
7-9: 생성자 위임 패턴 잘 구현됨기본 생성자가 매개변수 있는 생성자를 호출하는 위임 패턴이 올바르게 구현되어 있습니다.
src/main/java/inheritance/PoisonSlime.java (2)
4-4: 필드 캡슐화 잘 구현됨poisonCount 필드가 private으로 적절히 캡슐화되어 있습니다.
17-23: 잠재적 HP 5 미만 시 독 데미지 ‘0’ 처리 검토
현재src/main/java/inheritance/PoisonSlime.java의 17–23행에서int damage = hero.getHp() / 5; hero.setHp(hero.getHp() - damage);로 계산하기 때문에 히어로 HP가 5 미만이면
damage가 0이 됩니다.
의도한 동작인지 확인해 주세요.
필요하다면 최소 1 이상의 데미지를 보장하거나, 이 경계값을 다루는 로직 및 테스트 케이스를 추가하는 것을 권장합니다.src/main/java/inheritance/Slime.java (2)
4-5: 필드 캡슐화 잘 구현됨필드들이 private으로 적절히 캡슐화되어 있고, suffix는 final로 선언되어 불변성을 보장하고 있습니다.
21-26: attack() 메소드 구현 잘 됨공격 로직이 명확하게 구현되어 있고, Hero 객체와의 상호작용이 적절히 처리되어 있습니다.
src/main/java/inheritance/GreatWizard.java (2)
3-4: 클래스 구조와 필드 초기화가 올바릅니다.상속 관계와 mp 필드 초기화가 적절하게 구현되었습니다.
6-10: heal 메서드 오버라이드가 올바르게 구현되었습니다.부모 클래스의 heal 메서드를 적절히 오버라이드하여 더 강력한 힐링 효과(25 HP 회복)를 제공합니다.
src/test/java/com/survivalcoding/WandTest.java (2)
11-18: 테스트 설정이 올바르게 구현되었습니다.@beforeeach와 @AfterEach를 사용한 테스트 라이프사이클 관리가 적절합니다.
25-45: 테스트 케이스들이 잘 작성되었습니다.지팡이 이름 검증 로직을 포괄적으로 테스트하고 있으며, 경계값 테스트도 포함되어 있습니다. @DisplayName을 사용한 테스트 설명도 명확합니다.
src/main/java/generic/Pocket.java (1)
6-17: 제네릭 클래스 구현이 올바릅니다.타입 파라미터 E를 사용한 제네릭 클래스와 put/get 메서드가 적절하게 구현되었습니다.
src/main/java/inheritance/Hero.java (3)
3-31: 클래스 기본 구조가 올바르게 구현되었습니다.생성자와 getter/setter 메서드들이 적절하게 구현되었습니다.
34-37: attack 메서드의 로직을 확인해주세요.Hero가 공격할 때 자신의 HP가 감소하는 것이 의도된 동작인지 확인이 필요합니다. 일반적으로는 공격받은 대상의 HP가 감소해야 합니다.
이것이 의도된 게임 로직인지, 아니면 다음과 같이 수정해야 하는지 확인해주세요:
public void attack(Slime slime) { System.out.println(name + "이 공격했다"); - hp -= 10; + // slime.takeDamage(10); // 또는 적절한 데미지 로직 }
44-48: slip 메서드가 올바르게 구현되었습니다.final 키워드를 사용하여 오버라이드를 방지한 것이 적절하며, 메서드 로직도 명확합니다.
src/main/java/com/survivalcoding/Wand.java (2)
21-29: setName 메서드의 검증 로직이 훌륭합니다.null 체크와 길이 검증이 적절하게 구현되었고, 예외 메시지도 명확합니다.
36-42: setPower 메서드의 범위 검증이 올바릅니다.0.5부터 100.0까지의 범위 검증이 적절하게 구현되었습니다.
src/main/java/com/survivalcoding/SuperHero.java (1)
26-35: attack 메소드의 중복 호출 확인 필요
super.attack(kinoko)가 두 번 호출되고 있습니다 (28번째와 34번째 줄). 이것이 의도된 동작인지 확인해주세요. 만약 슈퍼히어로의 공격이 두 번의 일반 공격 + 비행 중 추가 효과를 의미한다면 괜찮지만, 그렇지 않다면 중복 호출일 수 있습니다.src/main/java/inheritance/SuperHero.java (1)
25-34: attack 메소드 로직 검토 필요28번째 줄에서 공격하는 hero의 hp를 감소시키고 있습니다 (
setHp(getHp() - 10)). 일반적으로 공격 시에는 공격자가 아닌 피공격자의 hp가 감소해야 합니다. 이것이 의도된 동작(예: 공격 시 체력 소모)인지 확인해주세요.만약 공격자의 체력 소모가 의도되지 않았다면 다음과 같이 수정을 고려해보세요:
@Override public void attack(Slime slime) { System.out.println(getName() + "이 공격했다"); - setHp(getHp() - 10); if (isFlying) { slime.setHP(slime.getHP() - 5); System.out.println("5포인트의 추가 피해를 입혔다"); } }src/test/java/com/survivalcoding/PoisonSlimeTest.java (1)
35-52: 테스트 로직 승인독 공격이 소진된 후 일반 데미지만 적용되는지 확인하는 테스트 로직이 잘 구현되어 있습니다.
src/main/java/com/survivalcoding/PoisonSlime.java (1)
3-7: DEFAULT_DAMAGE 상수는 Slime 클래스에 정의되어 있음 확인됨Slime 클래스(src/main/java/com/survivalcoding/Slime.java:6)에서
public static final int DEFAULT_DAMAGE = 10;으로 선언되어 있어, PoisonSlime에서도 상속된 static 필드를 참조하는 것이므로 별도 정의가 필요 없습니다.
src/test/java/inheritance/PoisonSlimeTest.java (2)
64-66: 테스트에서 메서드 반환값 검증을 추가하세요.pray() 메서드가 반환값을 가진다면, 테스트에서 이를 검증해야 합니다.
poisonSlime.attack(hero1); + // attack 메서드의 반환값이 있다면 검증 추가Likely an incorrect or invalid review comment.
22-22: 상수 참조 유효성 확인 완료
– PoisonSlime.DEFAULT_POISON_COUNT는src/main/java/com/survivalcoding/PoisonSlime.java에 정의되어 있습니다.
– PoisonSlime.DEFAULT_DAMAGE는Slime클래스의 static 상수(src/main/java/com/survivalcoding/Slime.java)로, 상속을 통해 정상 참조 가능합니다.따라서 테스트 코드 수정이나 상수 추가 작업은 불필요합니다.
src/main/java/com/survivalcoding/Cleric.java (1)
9-11: 중복 선언 아님:Character클래스에name·hp필드가 정의되어 있지 않습니다
Character.java를 확인한 결과 해당 필드가 없으므로,Cleric에서 선언된name과hp는 중복이 아닙니다. 이 리뷰 코멘트는 무시하셔도 좋습니다.Likely an incorrect or invalid review comment.
src/main/java/com/survivalcoding/game.puml (1)
39-47: Cleric 클래스의 상속 관계가 실제 코드와 일치하지 않습니다실제 Java 코드에서는 Cleric이 Character를 상속하지만, 다이어그램에서는 독립적인 클래스로 표시되어 있습니다.
-class Cleric { +class Cleric extends Character { + String name - int hp + int mp - + void attack(Kinoko enemy) + + void attack(Slime slime) + void pray(int sec) + void selfAid() }또한 attack 메서드의 매개변수 타입도 실제 코드와 일치시켜야 합니다.
Likely an incorrect or invalid review comment.
src/main/java/inheritance/inheritance.puml (1)
1-54: 잘 구성된 상속 다이어그램입니다클래스 계층 구조와 메서드 오버라이딩이 명확하게 표현되어 있습니다.
src/main/java/com/survivalcoding/Hero.java (1)
5-5: Character 클래스 상속 확인 필요PlantUML 다이어그램에서는 Hero가 Character를 상속하는 것으로 표시되어 있지만, 실제 코드에서는 상속하지 않습니다.
설계 의도에 맞게 코드를 수정하거나 다이어그램을 업데이트하세요.
Likely an incorrect or invalid review comment.
src/main/java/com/survivalcoding/2025.07.01과제.puml (2)
1-13: 다이어그램 설정이 잘 구성되어 있습니다!테마 설정과 레이아웃 구성이 가독성을 높이는데 도움이 됩니다.
92-92: 인터페이스를 활용한 좋은 설계입니다!
BlackWidow의enhance메서드가IEnhanceable인터페이스를 파라미터로 받는 것은 타입 안정성과 유연성을 제공하는 좋은 설계입니다.
| @@ -0,0 +1,30 @@ | |||
| package com.survivalcoding; | |||
|
|
|||
| import java.util.Calendar; | |||
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.
🛠️ Refactor suggestion
최신 Java Time API 사용을 권장합니다.
Calendar 클래스 대신 Java 8 이후 도입된 java.time.LocalDate를 사용하는 것이 더 안전하고 명확합니다.
다음과 같이 수정할 수 있습니다:
-import java.util.Calendar;
+import java.time.LocalDate;- Calendar cal = Calendar.getInstance();그리고 getAge() 메서드에서:
- public int getAge() {
- int yy = cal.get(Calendar.YEAR);
- return yy - birthYear;
- }
+ public int getAge() {
+ return LocalDate.now().getYear() - birthYear;
+ }Also applies to: 8-8
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Person.java at line 3, replace the import of
java.util.Calendar with java.time.LocalDate to use the modern Java Time API.
Update the code to use LocalDate for date handling, especially in the getAge()
method, to improve safety and clarity. Apply similar changes around line 8 as
well.
| public class Person { | ||
| private final String name; | ||
| private final int birthYear; | ||
| Calendar cal = Calendar.getInstance(); |
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.
🛠️ Refactor suggestion
필드의 접근 제어자를 명시해야 합니다.
Calendar 필드가 package-private으로 선언되어 있습니다. 캡슐화를 위해 private으로 변경하거나, 최신 API 사용을 위해 제거하는 것이 좋습니다.
- Calendar cal = Calendar.getInstance();
+ private final Calendar cal = Calendar.getInstance();📝 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.
| Calendar cal = Calendar.getInstance(); | |
| private final Calendar cal = Calendar.getInstance(); |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Person.java at line 8, the Calendar field is
declared without an access modifier, making it package-private. To improve
encapsulation, change the field's access modifier to private or consider
removing it if it is unnecessary or replace it with a more modern API
alternative.
| public Person(String name, int birthYear) { | ||
| this.name = name; | ||
| this.birthYear = birthYear; | ||
|
|
||
| } |
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.
🛠️ Refactor suggestion
생성자에 유효성 검사를 추가하세요.
이름이 null이거나 출생년도가 현실적이지 않은 값(예: 음수, 미래년도)인 경우에 대한 검증이 필요합니다.
public Person(String name, int birthYear) {
+ if (name == null || name.trim().isEmpty()) {
+ throw new IllegalArgumentException("이름은 null이거나 빈 문자열일 수 없습니다.");
+ }
+ int currentYear = LocalDate.now().getYear();
+ if (birthYear < 1900 || birthYear > currentYear) {
+ throw new IllegalArgumentException("출생년도가 유효하지 않습니다.");
+ }
this.name = name;
this.birthYear = birthYear;
}📝 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 Person(String name, int birthYear) { | |
| this.name = name; | |
| this.birthYear = birthYear; | |
| } | |
| public Person(String name, int birthYear) { | |
| if (name == null || name.trim().isEmpty()) { | |
| throw new IllegalArgumentException("이름은 null이거나 빈 문자열일 수 없습니다."); | |
| } | |
| int currentYear = LocalDate.now().getYear(); | |
| if (birthYear < 1900 || birthYear > currentYear) { | |
| throw new IllegalArgumentException("출생년도가 유효하지 않습니다."); | |
| } | |
| this.name = name; | |
| this.birthYear = birthYear; | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Person.java around lines 10 to 14, the
constructor lacks validation for its parameters. Add checks to ensure the name
is not null and the birthYear is a realistic value (not negative and not in the
future). If any validation fails, throw an IllegalArgumentException with an
appropriate message to prevent invalid object creation.
| @Test | ||
| @DisplayName("2000년 생은 25살이다") | ||
| void getAge() { | ||
| Person person = new Person("홍길동", 2000); | ||
| assertEquals(25, person.getAge()); | ||
| } |
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.
🛠️ Refactor suggestion
테스트가 시간에 의존적입니다.
현재 테스트는 2000년생의 나이를 25살로 하드코딩하고 있어, 실행 시점에 따라 실패할 수 있습니다. 동적으로 기대값을 계산하거나 테스트 시점을 고정하는 방법을 고려해보세요.
다음과 같이 동적으로 기대값을 계산할 수 있습니다:
@Test
@DisplayName("2000년 생은 25살이다")
void getAge() {
Person person = new Person("홍길동", 2000);
- assertEquals(25, person.getAge());
+ int expectedAge = LocalDate.now().getYear() - 2000;
+ assertEquals(expectedAge, person.getAge());
}또는 더 명확한 테스트명으로 변경:
-@DisplayName("2000년 생은 25살이다")
+@DisplayName("출생년도를 기준으로 나이를 계산한다")📝 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.
| @Test | |
| @DisplayName("2000년 생은 25살이다") | |
| void getAge() { | |
| Person person = new Person("홍길동", 2000); | |
| assertEquals(25, person.getAge()); | |
| } | |
| @Test | |
| - @DisplayName("2000년 생은 25살이다") | |
| + @DisplayName("출생년도를 기준으로 나이를 계산한다") | |
| void getAge() { | |
| Person person = new Person("홍길동", 2000); | |
| - assertEquals(25, person.getAge()); | |
| + int expectedAge = LocalDate.now().getYear() - 2000; | |
| + assertEquals(expectedAge, person.getAge()); | |
| } |
🤖 Prompt for AI Agents
In src/test/java/com/survivalcoding/PersonTest.java around lines 10 to 15, the
test for the age of a person born in 2000 is hardcoded to expect 25 years, which
makes the test fail as time passes. To fix this, calculate the expected age
dynamically based on the current year minus the birth year, and use that value
in the assertion instead of a fixed number. Alternatively, fix the test date
context or rename the test to clarify the assumption about the current year.
|
|
||
| public class Book extends TangibleAsset { | ||
|
|
||
| String isbn; |
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.
🛠️ Refactor suggestion
캡슐화를 위해 isbn 필드를 private으로 변경하세요.
isbn 필드가 package-private으로 선언되어 있어 캡슐화 원칙을 위반합니다. getter/setter 메서드가 제공되므로 필드는 private으로 선언해야 합니다.
- String isbn;
+ private String isbn;📝 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.
| String isbn; | |
| - String isbn; | |
| + private String isbn; |
🤖 Prompt for AI Agents
In src/main/java/Asset/Book.java at line 5, the isbn field is declared with
package-private access, violating encapsulation principles. Change the access
modifier of the isbn field from default (package-private) to private to enforce
encapsulation, since getter and setter methods are already provided for
accessing this field.
| public void selfAid() { | ||
| if (hp == maxHp) return; // 이미 max라면 return | ||
| if (mp < 5) return; // mp가 부족하면 return | ||
| mp -= 5; | ||
|
|
||
| if (mp >= 5) { | ||
| if (hp < maxHp) { | ||
| hp = maxHp; | ||
| } | ||
| } | ||
|
|
||
| System.out.println(name + "셀프 에이드를 사용했습니다"); | ||
| System.out.println("HP가 전부 회복되었습니다"); | ||
| hp = maxHp; | ||
| } |
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.
selfAid() 메서드에 중복 로직 제거 필요
MP 검증과 HP 설정이 중복되어 있습니다.
public void selfAid() {
- if (hp == maxHp) return; // 이미 max라면 return
+ if (hp == MAX_HP) return; // 이미 max라면 return
if (mp < 5) return; // mp가 부족하면 return
mp -= 5;
-
- if (mp >= 5) {
- if (hp < maxHp) {
- hp = maxHp;
- }
- }
-
+ hp = MAX_HP;
System.out.println(name + "셀프 에이드를 사용했습니다");
System.out.println("HP가 전부 회복되었습니다");
- hp = maxHp;
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Cleric.java between lines 33 and 47, the
selfAid() method contains redundant checks for mp and hp and sets hp to maxHp
multiple times. Simplify the method by removing the repeated mp and hp condition
checks and ensure hp is set to maxHp only once after confirming sufficient mp
and that hp is not already full.
| public int pray(int sec) { | ||
| Random rand = new Random(); | ||
| if (mp == maxMp) return 0; // 이미 max라면 return | ||
|
|
||
| // 회복량 recoveryMp에 저장 | ||
| int recoveryMp = rand.nextInt(3) + sec; // 0~2 랜덤값 + 기도 시간(s) | ||
|
|
||
| // 0~2 보정치 추가 | ||
| int recovery = sec + rand.nextInt(3); | ||
|
|
||
| // 최대 MP를 넘지 않도록 | ||
| int actualRecovery = Math.min(maxMp - mp, recovery); | ||
| mp += actualRecovery; | ||
| System.out.println(name + "는 " + sec + "초 동안 기도하여 MP를 " | ||
| + actualRecovery + " 회복했습니다."); | ||
| return actualRecovery; | ||
| // maxMp 보다 더 회복하는가? | ||
| if (recoveryMp + mp > maxMp) { | ||
| recoveryMp = maxMp - mp; | ||
| } | ||
|
|
||
| // mp 회복 | ||
| mp += recoveryMp; | ||
| return recoveryMp; | ||
| } |
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.
pray() 메서드의 도달 불가능한 코드 제거 필요
return 문 이후의 코드는 실행되지 않습니다.
public int pray(int sec) {
Random rand = new Random();
- if (mp == maxMp) return 0; // 이미 max라면 return
-
- // 회복량 recoveryMp에 저장
- int recoveryMp = rand.nextInt(3) + sec; // 0~2 랜덤값 + 기도 시간(s)
+ if (mp == MAX_MP) return 0; // 이미 max라면 return
// 0~2 보정치 추가
int recovery = sec + rand.nextInt(3);
// 최대 MP를 넘지 않도록
- int actualRecovery = Math.min(maxMp - mp, recovery);
+ int actualRecovery = Math.min(MAX_MP - mp, recovery);
mp += actualRecovery;
System.out.println(name + "는 " + sec + "초 동안 기도하여 MP를 "
+ actualRecovery + " 회복했습니다.");
return actualRecovery;
- // maxMp 보다 더 회복하는가?
- if (recoveryMp + mp > maxMp) {
- recoveryMp = maxMp - mp;
- }
-
- // mp 회복
- mp += recoveryMp;
- return recoveryMp;
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Cleric.java between lines 50 and 74, the
pray() method contains unreachable code after a return statement. Remove all
code after the first return statement to eliminate unreachable code and ensure
the method logic is clear and correct.
| class Hero{ | ||
| + String name | ||
| - int hp | ||
| } |
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.
Hero 클래스가 중복 정의되어 있습니다
Hero 클래스가 두 번 정의되어 있어 다이어그램이 올바르게 표시되지 않을 수 있습니다.
첫 번째 Hero 클래스 정의(라인 17-20)를 제거하고, 두 번째 정의(라인 33-37)만 남겨두세요:
-class Hero{
- + String name
- - int hp
-}Also applies to: 33-37
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/game.puml between lines 17 and 20, the Hero
class is defined redundantly. Remove this first Hero class definition entirely
and keep only the second definition found between lines 33 and 37 to avoid
duplication and ensure the diagram renders correctly.
| public static void setRandomMoney() { | ||
| Hero.money = new Random().nextInt(1000); | ||
|
|
||
| Hero hero = new Hero("aaa", 10); | ||
| hero.name = "홍길동"; | ||
| } |
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.
🛠️ Refactor suggestion
setRandomMoney() 메서드에 불필요한 코드 제거
메서드의 목적과 관련 없는 Hero 인스턴스 생성 코드가 포함되어 있습니다.
public static void setRandomMoney() {
Hero.money = new Random().nextInt(1000);
-
- Hero hero = new Hero("aaa", 10);
- hero.name = "홍길동";
}📝 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 static void setRandomMoney() { | |
| Hero.money = new Random().nextInt(1000); | |
| Hero hero = new Hero("aaa", 10); | |
| hero.name = "홍길동"; | |
| } | |
| public static void setRandomMoney() { | |
| Hero.money = new Random().nextInt(1000); | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Hero.java between lines 57 and 62, the
setRandomMoney() method contains unnecessary code creating a Hero instance and
setting its name, which is unrelated to the method's purpose. Remove the lines
that instantiate the Hero object and assign the name, leaving only the code that
sets the static money field with a random value.
| private String name; | ||
| private int hp; | ||
| private int mp; |
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.
부모 클래스 필드와 중복 선언
Character 클래스를 상속받으면서 name과 hp를 다시 선언하고 있습니다. 이는 필드 섀도잉을 일으킵니다.
public class Wizard extends Character {
- private String name;
- private int hp;
private int mp;
private Wand wand;부모 클래스의 필드를 사용하도록 수정하세요.
📝 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.
| private String name; | |
| private int hp; | |
| private int mp; | |
| public class Wizard extends Character { | |
| private int mp; | |
| private Wand wand; | |
| // … | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Wizard.java lines 4 to 6, the fields 'name'
and 'hp' are redeclared in the Wizard class while they already exist in the
parent Character class, causing field shadowing. Remove the declarations of
'name' and 'hp' from Wizard and use the inherited fields from Character instead.
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.
Review continued from previous batch...
| void heal(Hero hero) { | ||
| int basePoint = 10; // 기본회복 포인트 | ||
| int recovPoint = (int) (basePoint * this.wand.getPower()); // 지팡이에 의한 증폭 | ||
| hero.setHp (hero.getHp() + recovPoint); // 용사의 HP를 회복 | ||
| } |
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.
heal 메서드에 null 검사 추가 필요
wand가 null인 경우 NullPointerException이 발생할 수 있습니다.
void heal(Hero hero) {
+ if (this.wand == null) {
+ System.out.println("지팡이가 없어 치유할 수 없습니다.");
+ return;
+ }
int basePoint = 10; // 기본회복 포인트
int recovPoint = (int) (basePoint * this.wand.getPower()); // 지팡이에 의한 증폭
hero.setHp (hero.getHp() + recovPoint); // 용사의 HP를 회복
}📝 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.
| void heal(Hero hero) { | |
| int basePoint = 10; // 기본회복 포인트 | |
| int recovPoint = (int) (basePoint * this.wand.getPower()); // 지팡이에 의한 증폭 | |
| hero.setHp (hero.getHp() + recovPoint); // 용사의 HP를 회복 | |
| } | |
| void heal(Hero hero) { | |
| if (this.wand == null) { | |
| System.out.println("지팡이가 없어 치유할 수 없습니다."); | |
| return; | |
| } | |
| int basePoint = 10; // 기본회복 포인트 | |
| int recovPoint = (int) (basePoint * this.wand.getPower()); // 지팡이에 의한 증폭 | |
| hero.setHp (hero.getHp() + recovPoint); // 용사의 HP를 회복 | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Wizard.java around lines 31 to 35, the heal
method does not check if the wand is null before accessing its power, which can
cause a NullPointerException. Add a null check for this.wand before using it; if
wand is null, use a default power value (e.g., 1) to calculate recovPoint
safely.
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.
🛠️ Refactor suggestion
메서드 명명 규칙과 파라미터 일관성 개선 필요
Java 명명 규칙에 따라 메서드명은 소문자로 시작해야 합니다. 또한 AllHeroesUseSkill 메서드가 모든 히어로에게 스킬을 사용하는 것이라면 hero 파라미터가 필요한지 재검토가 필요합니다.
다음과 같이 수정하는 것을 제안합니다:
- +void AllHeroesUseSkill(hero : Hero)
- +void AllHeroesMove()
+ +void allHeroesUseSkill()
+ +void allHeroesMove()또는 특정 히어로의 스킬을 사용하는 것이라면:
- +void AllHeroesUseSkill(hero : Hero)
+ +void heroUseSkill(hero : Hero)📝 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.
| +void AllHeroesUseSkill(hero : Hero) | |
| +void AllHeroesMove() | |
| +void allHeroesUseSkill() | |
| +void allHeroesMove() |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/2025.07.01과제.puml around lines 26 to 27, the
method names AllHeroesUseSkill and AllHeroesMove do not follow Java naming
conventions which require method names to start with a lowercase letter. Also,
the AllHeroesUseSkill method includes a hero parameter which is inconsistent if
the method is intended to apply a skill to all heroes. Rename the methods to
allHeroesUseSkill and allHeroesMove, and remove the hero parameter from
allHeroesUseSkill if it is meant to affect all heroes; otherwise, rename the
method to useSkill and keep the hero parameter if it targets a specific hero.
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.
Actionable comments posted: 7
🧹 Nitpick comments (9)
TIL/topics/java_basic/2025.07 2주.md (7)
5-12: 비격식 표현·추임새 제거 및 문장 다듬기 제안
해당 구간은 ‘장표는 몇장 안되요’, ‘어....’ 등 구어체·추임새가 많아 핵심 메시지가 희석됩니다. 간결한 서술형 문장으로 정리하면 가독성이 크게 향상됩니다.
24-29: 용어‧표현 통일 권장
‘파일 스트럭스??’, ‘M 은 매서드’처럼 한글·영문·축약이 뒤섞여 있습니다. 예) “파일 구조(File Structure)”∙“메서드(Method)” 식으로 표기를 통일하면 학습 자료로서 신뢰도가 높아집니다.
55-63: 불필요한 수수께끼식 질문 삭제 검토
“0,1 둘중에 하나 찍으시면 돼.” 등 퀴즈형 서술이 반복됩니다. 학습 흐름을 방해하므로, 실제 결과 값과 이유를 명시하는 설명형 문장으로 교체하는 편이 좋습니다.
64-72: List vs Set 성능 설명 보강 필요
현재는 “set은 속도가 굉장히 빨라요”만 언급돼 있어 빅-O 근거가 부족합니다.HashSet은 평균 O(1) 검색/삽입,ArrayList는 O(n) 선형 탐색임을 수치로 명시하면 이해가 쉬워집니다.필요하시다면 간단한 성능 비교 코드 예시를 제공해 드릴 수 있습니다.
124-135: 오탈자 및 비교 설명 정확성 개선
‘이헌게’ → ‘이런 게’ 등 타이포가 다수 존재하며,hashCode()비교는 ‘==’ 연산자가 아닌 “동일 해시 버킷 내 equals 재검사” 과정이 핵심임을 명확히 해 주세요.
174-188: 얕은‧깊은 복사 개념 구분 강화
Cloneable은 얕은 복사만 보장하며, 깊은 복사는 필드별 수동 복사 또는 직렬화 기반 구현이 필요합니다. 현재 설명이 혼재돼 있으니 구분 도식을 추가하면 좋겠습니다.
1-210: 전체 구조 리팩터링 제안
TIL 문서 전반이 구어체 중심이어서 참고 자료로 재사용하기 어렵습니다.
- Markdown 헤더(###)와 목록(-)으로 논리 단락 구분
- 코드 예시는 ```java 블록 활용
- 불필요한 감탄사·중복 공백 제거
아래와 같은 레이아웃을 추천드립니다:
## Object 클래스 핵심 메서드 - toString(): 객체 문자열 표현 오버라이딩 - equals()/hashCode(): 동등성 & 해시 규칙 (둘 다 재정의 필수) ## 컬렉션 비교 | 컬렉션 | 평균 검색 속도 | 특징 | |--------|----------------|------| | ArrayList | O(n) | 순차 검색 | | HashSet | O(1) | 해시 기반 | ## 얕은 복사 vs 깊은 복사 ...src/main/java/aa.java (2)
3-3: Java 명명 규칙 준수 권장클래스명
aa는 Java 명명 규칙을 따르지 않습니다. 클래스명은 PascalCase를 사용해야 합니다.더 의미 있는 이름으로 변경하는 것을 권장합니다:
-public class aa { +public class InputHandler {또는 최소한 다음과 같이 변경하세요:
-public class aa { +public class Aa {
3-6: 학습 목적의 클래스 구조 개선 제안현재 클래스는 Scanner만 선언되어 있고 실제 기능이 없습니다. 학습 목적이라면 기본적인 메소드를 추가하는 것이 좋겠습니다.
다음과 같은 구조를 고려해보세요:
import java.util.Scanner; public class InputHandler { private Scanner sc = new Scanner(System.in); public String readString() { return sc.nextLine(); } public int readInt() { return sc.nextInt(); } public void close() { sc.close(); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
TIL/topics/java_basic/2025.07 1주.md(1 hunks)TIL/topics/java_basic/2025.07 2주.md(1 hunks)TIL/topics/java_basic/용어정리.md(1 hunks)src/main/java/aa.java(1 hunks)src/main/java/generic/EnumMain.java(1 hunks)src/main/java/instance/ListMain.java(1 hunks)src/main/java/instance/SetMain.java(1 hunks)src/main/java/instance/ToString.java(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- TIL/topics/java_basic/용어정리.md
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/java/generic/EnumMain.java
- TIL/topics/java_basic/2025.07 1주.md
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
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.
Actionable comments posted: 6
♻️ Duplicate comments (2)
src/main/java/com/survivalcoding/Slime.java (2)
5-5: Monster 클래스의 추상 메서드 attack()을 구현하세요.Monster 클래스의 추상 메서드 attack()을 구현하지 않았습니다. 현재 Hero를 매개변수로 받는 attack(Hero hero) 메서드가 있지만, 부모 클래스의 attack() 메서드도 구현해야 합니다.
+ @Override + public void attack() { + System.out.println(prefix + " 슬라임이 공격합니다!"); + }
9-9: 중복된 hp 필드를 제거하세요.Monster 클래스에 이미 hp 필드가 있으므로 중복 정의할 필요가 없습니다. 부모 클래스의 hp 필드를 사용하거나 getter/setter를 통해 접근하세요.
Monster 클래스의 hp 필드를 protected로 변경하거나 getter/setter를 추가한 후, 이 중복 필드를 제거하세요.
- private int hp;
🧹 Nitpick comments (8)
TIL/topics/java_basic/2025.07 2주.md (5)
29-35: 오탈자 및 용어 수정 제안
타입 하이러하키,있스비다등 오타·비표준 표현이 포함돼 문서 가독성이 떨어집니다. 간단한 맞춤법 교정만으로도 전달력이 크게 향상됩니다.-타입 하이러하키 창을 켜면 -모든 상속 관계를 볼 수 있스비다. +타입 계층(Type Hierarchy) 창을 열면 +모든 상속 관계를 확인할 수 있습니다.
38-45: 불완전 문장으로 인한 의미 전달 누락
퍼블릭 클래스 오브젝트 해가주고,파일 스트럭스??,PPT에서 언급하는 것들이 중요하는 거지등은 문장이 매끄럽지 않아 독자가 의도를 파악하기 어렵습니다. 불필요한 구어체·의성어를 제거하고 핵심 개념을 한 문장으로 정리해 주세요.
63-70: Markdown 파싱 오류 가능성
static은 모아 놓을 게요\처럼 역슬래시로 끝나는 줄은 마크다운 렌더러에 따라 다음 줄과 병합돼 의도치 않은 결과를 낼 수 있습니다. 줄 끝 역슬래시는 삭제하거나 코드 블록으로 감싸 주세요.-static은 모아 놓을 게요\ +static 멤버는 별도 구역에 모아두겠습니다.
80-88: 성능 비교 근거 보강 필요
set은 속도가 굉장히 빨라요.만으로는 왜 빠른지, 어떤 연산 기준인지 불명확합니다. 해시 기반 자료구조의 Big-O 복잡도를 간단히 언급하면 학습 자료로서 완성도가 높아집니다.예시:
- Set은 속도가 굉장히 빨라요. + Set(특히 HashSet)은 해시 테이블을 사용하므로 평균적으로 + 추가·검색·삭제 연산이 O(1) 입니다.
108-113:equals/hashCode설명 정교화 및 오타
Hash 값 기준으로 동등성 체크르 해요→Hash 값 기준으로 동등성 체크를 해요등 오타가 있습니다. 또한 “둘 다 해줘야 해요” 부분에동일 필드를 기반으로 equals와 hashCode를 모두 재정의해야 한다는 이유(계약 위반 위험)를 한 문장만 추가하면 이해도가 높아집니다.src/main/java/com/survivalcoding/PoisonSlime.java (1)
25-32: 체력 검증 로직을 추가하세요.독 데미지 적용 후 영웅의 체력이 음수가 될 수 있습니다. 체력 관리의 일관성을 위해 검증 로직을 추가하는 것이 좋습니다.
int damage = hero.getHp() / 5; - hero.setHp(hero.getHp() - damage); + hero.setHp(Math.max(0, hero.getHp() - damage)); System.out.println(damage + "포인트의 데미지");src/main/java/com/survivalcoding/Slime.java (1)
42-44: run() 메서드 구현을 의미있게 개선하세요.현재 run() 메서드가 단순히 "2"를 출력하는 것은 의미가 없습니다. 슬라임의 도망 동작을 나타내는 적절한 메시지나 로직으로 개선하세요.
@Override public void run() { - System.out.println("2"); + System.out.println(prefix + " 슬라임이 도망갑니다!"); }src/main/java/instance/Book.java (1)
9-9: comment 필드 초기화를 고려하세요.
comment필드가 정의되어 있지만 생성자에서 초기화되지 않습니다. 이는 의도적일 수 있지만, null 값 처리에 주의가 필요합니다.생성자에 comment 매개변수를 추가하거나 기본값을 설정하는 것을 고려해보세요:
- public Book(String title, Date publishDate) { + public Book(String title, Date publishDate, String comment) { this.title = title; this.publishDate = publishDate; + this.comment = comment; }또는 기본값을 설정하세요:
- private String comment; + private String comment = "";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
TIL/topics/java_basic/2025.07 2주.md(1 hunks)src/main/java/aa.java(1 hunks)src/main/java/com/survivalcoding/Main.java(1 hunks)src/main/java/com/survivalcoding/PoisonSlime.java(1 hunks)src/main/java/com/survivalcoding/Slime.java(1 hunks)src/main/java/instance/Book.java(1 hunks)src/main/java/instance/BookList.java(1 hunks)src/main/java/instance/BookSet.java(1 hunks)src/main/java/instance/ListMain.java(1 hunks)src/main/java/instance/SetMain.java(1 hunks)src/main/java/instance/ToString.java(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/main/java/aa.java
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/java/com/survivalcoding/Main.java
- src/main/java/instance/ToString.java
- src/main/java/instance/SetMain.java
- src/main/java/instance/ListMain.java
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
🧬 Code Graph Analysis (1)
src/main/java/com/survivalcoding/Slime.java (1)
src/main/java/Monster/Monster.java (1)
Monster(3-11)
🔇 Additional comments (3)
src/main/java/instance/BookSet.java (1)
11-12: deprecated된 Date 생성자 사용을 개선하세요.
Date(int year, int month, int date, int hrs, int min)생성자는 JDK 1.1부터 deprecated되었습니다. 대신Calendar클래스나LocalDateTime을 사용하는 것을 권장합니다.다음과 같이 수정하세요:
-import java.util.Date; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; - Book b1 = new Book("aaa", new Date(2025, 1, 1, 1, 1)); - Book b2 = new Book("bbb", new Date(2025, 2, 1, 2, 2)); + Book b1 = new Book("aaa", Date.from(LocalDateTime.of(2025, 1, 1, 1, 1).atZone(ZoneId.systemDefault()).toInstant())); + Book b2 = new Book("bbb", Date.from(LocalDateTime.of(2025, 2, 1, 2, 2).atZone(ZoneId.systemDefault()).toInstant()));⛔ Skipped due to learnings
Learnt from: Yuny2036 PR: SurvivalCodingCampus/polytech_java_study#170 File: src/main/java/com/survivalcoding/asset/Book.java:69-78 Timestamp: 2025-07-07T08:33:32.454Z Learning: In the `SurvivalCodingCampus/polytech_java_study` repository, students may be explicitly instructed to use deprecated methods like `Date.getYear()`, `Date.getMonth()`, and `Date.getDay()` for educational purposes, even though these methods are deprecated. This is intentional for learning objectives and should not be flagged as issues requiring modernization.src/main/java/instance/Book.java (2)
55-56: deprecated된 Date 생성자 사용을 개선하세요.
Date(int year, int month, int date)생성자는 JDK 1.1부터 deprecated되었습니다.다음과 같이 수정하세요:
-import java.util.Date; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Date; - Book book1 = new Book("aaa", new Date(2025, 1, 1)); - Book book2 = new Book("bbb", new Date(2025, 2, 1)); + Book book1 = new Book("aaa", Date.from(LocalDate.of(2025, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())); + Book book2 = new Book("bbb", Date.from(LocalDate.of(2025, 2, 1).atStartOfDay(ZoneId.systemDefault()).toInstant()));⛔ Skipped due to learnings
Learnt from: Yuny2036 PR: SurvivalCodingCampus/polytech_java_study#170 File: src/main/java/com/survivalcoding/asset/Book.java:69-78 Timestamp: 2025-07-07T08:33:32.454Z Learning: In the `SurvivalCodingCampus/polytech_java_study` repository, students may be explicitly instructed to use deprecated methods like `Date.getYear()`, `Date.getMonth()`, and `Date.getDay()` for educational purposes, even though these methods are deprecated. This is intentional for learning objectives and should not be flagged as issues requiring modernization.
45-45: deprecated된 getYear() 메서드를 수정하세요.
Date.getYear()메서드는 JDK 1.1부터 deprecated되었습니다.다음과 같이 수정하세요:
+import java.time.LocalDate; +import java.time.ZoneId; - Objects.equals(publishDate.getYear(), book.publishDate.getYear()); + Objects.equals(publishDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear(), + book.publishDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear());⛔ Skipped due to learnings
Learnt from: Yuny2036 PR: SurvivalCodingCampus/polytech_java_study#170 File: src/main/java/com/survivalcoding/asset/Book.java:69-78 Timestamp: 2025-07-07T08:33:32.454Z Learning: In the `SurvivalCodingCampus/polytech_java_study` repository, students may be explicitly instructed to use deprecated methods like `Date.getYear()`, `Date.getMonth()`, and `Date.getDay()` for educational purposes, even though these methods are deprecated. This is intentional for learning objectives and should not be flagged as issues requiring modernization.
| int damage = hero.getHp() / 5; | ||
| hero.setHp(hero.getHp() - damage); |
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.
🛠️ Refactor suggestion
독 데미지 계산 로직을 개선하세요.
현재 독 데미지가 hero.getHp() / 5로 계산되어 있어 다음과 같은 문제점들이 있습니다:
- 영웅의 체력이 5 미만일 때 정수 나눗셈으로 인해 독 데미지가 0이 됩니다
- 체력이 감소할수록 독 데미지도 감소하여 독의 지속적인 위협이 줄어듭니다
- int damage = hero.getHp() / 5;
+ int damage = Math.max(1, hero.getHp() / 5); // 최소 1 데미지 보장또는 고정 독 데미지 사용을 고려해보세요:
- int damage = hero.getHp() / 5;
+ int damage = 2; // 고정 독 데미지📝 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.
| int damage = hero.getHp() / 5; | |
| hero.setHp(hero.getHp() - damage); | |
| // before | |
| - int damage = hero.getHp() / 5; | |
| + int damage = Math.max(1, hero.getHp() / 5); // 최소 1 데미지 보장 | |
| hero.setHp(hero.getHp() - damage); |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/PoisonSlime.java around lines 28 to 29, the
poison damage calculation uses integer division hero.getHp() / 5, which results
in zero damage when hero's HP is below 5 and decreases damage as HP lowers,
reducing poison threat. To fix this, replace the calculation with a fixed damage
value or ensure a minimum damage threshold so poison damage remains consistent
regardless of current HP.
| Slime slime = new Slime("", 10); | ||
| Monster monster = new Slime("", 10); |
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.
추상 클래스 직접 인스턴스화 오류를 수정하세요.
추상 클래스 Slime을 직접 인스턴스화할 수 없습니다. 이 코드는 컴파일 오류를 발생시킵니다.
구체적인 Slime 하위 클래스를 생성하거나 main 메서드를 제거하세요:
- Slime slime = new Slime("", 10);
- Monster monster = new Slime("", 10);
+ // 구체적인 하위 클래스 사용 필요
+ // 예: PoisonSlime slime = new ConcreteSlime("", 10);📝 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.
| Slime slime = new Slime("", 10); | |
| Monster monster = new Slime("", 10); | |
| // 구체적인 하위 클래스 사용 필요 | |
| // 예: PoisonSlime slime = new ConcreteSlime("", 10); |
🤖 Prompt for AI Agents
In src/main/java/com/survivalcoding/Slime.java at lines 47-48, the code attempts
to instantiate the abstract class Slime directly, which causes a compilation
error. To fix this, replace the instantiation with a concrete subclass of Slime
or remove the instantiation if not needed. Ensure that only concrete classes are
instantiated.
| bookList.remove(b2); | ||
| System.out.println(bookList.size()); |
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.
💡 Verification agent
🧩 Analysis chain
HashSet 동작 확인이 필요합니다.
b2를 추가하지 않고 바로 제거하려고 시도하고 있습니다. 이는 HashSet의 동작을 테스트하는 의도로 보이지만, Book 클래스의 equals와 hashCode 구현에 불일치가 있어 예상과 다른 결과가 나올 수 있습니다.
Book 클래스의 equals/hashCode 구현이 올바른지 확인해보세요:
🏁 Script executed:
#!/bin/bash
# Description: Book 클래스의 equals와 hashCode 구현 확인
# Book 클래스의 equals 메서드 검색
ast-grep --pattern $'equals(Object $_) {
$$$
}'
# Book 클래스의 hashCode 메서드 검색
ast-grep --pattern $'hashCode() {
$$$
}'Length of output: 94
🏁 Script executed:
#!/bin/bash
# Book 클래스 파일 위치와 equals/hashCode 구현을 직접 검색합니다.
# 1. Book 클래스 파일 경로 찾기
echo "=== 찾아진 Book 클래스 파일 ==="
rg "class Book" -n
# 2. 해당 파일에서 equals 및 hashCode 메서드 검색
echo "=== equals 메서드 ==="
rg -n "equals\s*\(" --glob "*Book.java"
echo "=== hashCode 메서드 ==="
rg -n "hashCode\s*\(" --glob "*Book.java"Length of output: 906
🏁 Script executed:
#!/bin/bash
# BookSet.java 전체 내용을 확인합니다.
echo "=== src/main/java/instance/BookSet.java ==="
sed -n '1,200p' src/main/java/instance/BookSet.javaLength of output: 635
🏁 Script executed:
#!/bin/bash
# Book.java 내용 확인
echo "=== src/main/java/instance/Book.java ==="
sed -n '1,200p' src/main/java/instance/Book.javaLength of output: 1455
equals()와 hashCode() 불일치 수정 필요
Book 클래스의 equals 메서드에서는 publishDate.getYear()만 비교하지만, hashCode 메서드는 전체 publishDate 객체를 사용하고 있어 HashSet과 같은 컬렉션에서 일관되지 않은 동작을 유발할 수 있습니다.
다음 사항을 수정하세요:
- 파일:
src/main/java/instance/Book.java- equals() (라인 41–46)와 hashCode() (라인 49)에서 동일한 필드를 사용하도록 맞춥니다.
예시 변경안:
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
Book book = (Book) o;
- return Objects.equals(title, book.title) &&
- Objects.equals(publishDate.getYear(), book.publishDate.getYear());
+ return Objects.equals(title, book.title) &&
+ Objects.equals(publishDate.getYear(), book.publishDate.getYear());
}
@Override
public int hashCode() {
- return Objects.hash(title, publishDate);
+ return Objects.hash(title, publishDate.getYear());
}또는, 날짜 전체 비교가 필요하다면 equals()에서도 publishDate 객체 전체를 비교하도록 변경하세요.
📝 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.
| bookList.remove(b2); | |
| System.out.println(bookList.size()); | |
| @Override | |
| public boolean equals(Object o) { | |
| if (o == null || getClass() != o.getClass()) return false; | |
| Book book = (Book) o; | |
| return Objects.equals(title, book.title) && | |
| Objects.equals(publishDate.getYear(), book.publishDate.getYear()); | |
| } | |
| @Override | |
| public int hashCode() { | |
| return Objects.hash(title, publishDate.getYear()); | |
| } |
🤖 Prompt for AI Agents
In src/main/java/instance/Book.java around lines 41 to 49, the equals() method
compares only publishDate.getYear() while hashCode() uses the entire publishDate
object, causing inconsistency. To fix this, update both equals() and hashCode()
methods to use the same fields consistently: either compare only the year part
of publishDate in both methods or compare the entire publishDate object in both.
Make sure the fields used in equals() match exactly those used in hashCode().
| bookList.remove(b2); | ||
| System.out.println(bookList.size()); //0 | ||
|
|
||
| Collections.sort(); |
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.
Collections.sort() 호출을 완성하세요.
Collections.sort() 메서드 호출이 불완전하여 컴파일 오류가 발생합니다.
다음과 같이 수정하세요:
- Collections.sort();
+ Collections.sort(bookList);또는 Book 클래스가 Comparable 인터페이스를 구현하지 않은 경우 Comparator를 제공해야 합니다:
- Collections.sort();
+ Collections.sort(bookList, Comparator.comparing(Book::getTitle));🤖 Prompt for AI Agents
In src/main/java/instance/BookList.java at line 21, the call to
Collections.sort() is incomplete and causes a compilation error. Fix this by
passing the list of books to be sorted as the first argument. If the Book class
does not implement Comparable, provide a Comparator as the second argument to
define the sorting order.
| Book b1 = new Book("aaa", new Date(2025, 1, 1, 1, 1)); | ||
| Book b2 = new Book("aaa", new Date(2025, 1, 1, 2, 2)); |
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.
🛠️ Refactor suggestion
deprecated된 Date 생성자 사용을 개선하세요.
Date(int year, int month, int date, int hrs, int min) 생성자는 JDK 1.1부터 deprecated되었습니다. 또한 두 Book 객체가 동일한 제목을 가지고 있어 equals 메서드 동작을 테스트하는 의도로 보입니다.
다음과 같이 수정하세요:
-import java.util.Date;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Date;
- Book b1 = new Book("aaa", new Date(2025, 1, 1, 1, 1));
- Book b2 = new Book("aaa", new Date(2025, 1, 1, 2, 2));
+ Book b1 = new Book("aaa", Date.from(LocalDateTime.of(2025, 1, 1, 1, 1).atZone(ZoneId.systemDefault()).toInstant()));
+ Book b2 = new Book("aaa", Date.from(LocalDateTime.of(2025, 1, 1, 2, 2).atZone(ZoneId.systemDefault()).toInstant()));📝 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.
| Book b1 = new Book("aaa", new Date(2025, 1, 1, 1, 1)); | |
| Book b2 = new Book("aaa", new Date(2025, 1, 1, 2, 2)); | |
| // at top of src/main/java/instance/BookList.java | |
| -import java.util.Date; | |
| +import java.time.LocalDateTime; | |
| +import java.time.ZoneId; | |
| +import java.util.Date; | |
| … | |
| // original lines 12–13, updated to use Instant instead of deprecated constructor | |
| - Book b1 = new Book("aaa", new Date(2025, 1, 1, 1, 1)); | |
| - Book b2 = new Book("aaa", new Date(2025, 1, 1, 2, 2)); | |
| + Book b1 = new Book("aaa", | |
| + Date.from(LocalDateTime.of(2025, 1, 1, 1, 1) | |
| + .atZone(ZoneId.systemDefault()) | |
| + .toInstant())); | |
| + Book b2 = new Book("aaa", | |
| + Date.from(LocalDateTime.of(2025, 1, 1, 2, 2) | |
| + .atZone(ZoneId.systemDefault()) | |
| + .toInstant())); | |
| … |
🤖 Prompt for AI Agents
In src/main/java/instance/BookList.java around lines 12 to 13, the Date
constructor used is deprecated. Replace the deprecated Date constructor with
Calendar or LocalDateTime to create the Date objects properly. For example, use
Calendar to set the year, month, day, hour, and minute, then get the Date from
it. Also, ensure the two Book objects have the same title to test the equals
method as intended.
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.
Actionable comments posted: 5
🧹 Nitpick comments (5)
TIL/topics/java_basic/2025.07 2주.md (4)
232-232: URL을 마크다운 링크 문법으로 감싸 주세요
MarkdownLintMD034(no-bare-urls) 경고가 발생합니다. 가독성과 자동 링크 파싱을 돕기 위해 다음과 같이 수정하는 편이 좋습니다.-https://backlog.com/ja/git-tutorial/stepup/06/ +[Backlog Git 튜토리얼 Step-up 06](https://backlog.com/ja/git-tutorial/stepup/06/)
67-68: 문장 끝의 백슬래시() 삭제 권장
67행 끝의\문자는 마크다운에서 다음 줄 개행을 이스케이프하는 용도로 해석됩니다. 의도한 효과가 아니라면 제거해 주세요.
32-35: 오탈자 및 표현 개선 제안
타입 하이러하키,있스비다등 철자 오류가 눈에 띕니다. 학습 노트라 하더라도 오탈자를 수정하면 가독성과 검색 편의성이 향상됩니다. 빠르게 교정해 주세요.
1-1: 파일명에 공백 사용 자제 권장
2025.07 2주.md처럼 공백이 포함된 파일명은 OS·툴별 호환성 문제를 일으킬 수 있습니다.2025.07-2주.md등으로 변경을 고려해 주세요.src/main/java/instance/Book.java (1)
65-66: deprecated Date 생성자 사용에 대한 참고사항Date 생성자가 deprecated되었지만, 학습 목적으로 사용이 허용될 수 있습니다. 참고로 현재 코드는 2025년이 아닌 3925년으로 설정됩니다 (연도에 1900이 더해짐).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
TIL/topics/java_basic/2025.07 2주.md(1 hunks)src/main/java/instance/Book.java(1 hunks)src/test/java/instance/BookTest.java(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
src/test/java/instance/BookTest.java (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#171
File: src/main/java/instance/Book.java:26-33
Timestamp: 2025-07-07T22:36:29.730Z
Learning: Book 클래스의 compareTo 메서드는 publishDate를 기준으로 최신순(내림차순) 정렬을 수행한다. 즉, 더 최근 날짜가 앞에 오도록 정렬한다.
TIL/topics/java_basic/2025.07 2주.md (1)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#1
File: Readme.md:1-1
Timestamp: 2025-06-09T02:30:37.051Z
Learning: The repository `SurvivalCodingCampus/polytech_java_study` is used for class practice exercises, so minimal documentation in files like README.md may be intentional and acceptable for educational purposes.
src/main/java/instance/Book.java (2)
Learnt from: Hae1Won1
PR: SurvivalCodingCampus/polytech_java_study#171
File: src/main/java/instance/Book.java:26-33
Timestamp: 2025-07-07T22:36:29.730Z
Learning: Book 클래스의 compareTo 메서드는 publishDate를 기준으로 최신순(내림차순) 정렬을 수행한다. 즉, 더 최근 날짜가 앞에 오도록 정렬한다.
Learnt from: Yuny2036
PR: SurvivalCodingCampus/polytech_java_study#170
File: src/main/java/com/survivalcoding/asset/Book.java:69-78
Timestamp: 2025-07-07T08:33:32.479Z
Learning: In the `SurvivalCodingCampus/polytech_java_study` repository, students may be explicitly instructed to use deprecated methods like `Date.getYear()`, `Date.getMonth()`, and `Date.getDay()` for educational purposes, even though these methods are deprecated. This is intentional for learning objectives and should not be flagged as issues requiring modernization.
🪛 markdownlint-cli2 (0.17.2)
TIL/topics/java_basic/2025.07 2주.md
232-232: Bare URL used
(MD034, no-bare-urls)
🔇 Additional comments (1)
src/main/java/instance/Book.java (1)
41-45: equals 메서드 구현이 올바르게 수정되었습니다.이전 리뷰에서 지적된 equals/hashCode 일관성 문제가 수정되었습니다. 현재 두 메서드 모두 title과 publishDate를 사용하여 일관성을 유지하고 있습니다.
| void shouldConsiderBookWithSameTitleAndPublicationDateAsEqual() { | ||
| Calendar calendar = Calendar.getInstance(); | ||
| calendar.set(Calendar.YEAR, 2024); | ||
| calendar.set(Calendar.MONTH, 1); |
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.
Calendar 월 설정 오류를 수정하세요.
Calendar.MONTH는 0부터 시작하므로 1월을 설정하려면 0을 사용해야 합니다. 현재 코드는 2월을 설정합니다.
- calendar.set(Calendar.MONTH, 1);
+ calendar.set(Calendar.MONTH, 0);📝 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.
| calendar.set(Calendar.MONTH, 1); | |
| calendar.set(Calendar.MONTH, 0); |
🤖 Prompt for AI Agents
In src/test/java/instance/BookTest.java at line 15, the code sets the month
using calendar.set(Calendar.MONTH, 1), which incorrectly sets February instead
of January because Calendar.MONTH is zero-based. Change the value from 1 to 0 to
correctly set the month to January.
| Calendar calendar = Calendar.getInstance(); | ||
| calendar.set(Calendar.YEAR, 2024); | ||
| calendar.set(Calendar.MONTH, 1); | ||
| Calendar.set(Calendar.DAY_OF_MONTH, 1); |
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.
문법 오류를 수정하세요.
Calendar.set 대신 calendar.set을 사용해야 합니다.
- Calendar.set(Calendar.DAY_OF_MONTH, 1);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);📝 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.
| Calendar.set(Calendar.DAY_OF_MONTH, 1); | |
| calendar.set(Calendar.DAY_OF_MONTH, 1); |
🤖 Prompt for AI Agents
In src/test/java/instance/BookTest.java at line 16, replace the incorrect static
call Calendar.set with the instance method call calendar.set, using the
lowercase variable name 'calendar' to fix the syntax error.
| void shouldConsiderBookWithSameTitleAndPublicationDateAsEqual() { | ||
| Calendar calendar = Calendar.getInstance(); | ||
| calendar.set(Calendar.YEAR, 2024); | ||
| calendar.set(Calendar.MONTH, 1); | ||
| Calendar.set(Calendar.DAY_OF_MONTH, 1); | ||
|
|
||
|
|
||
| } |
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.
🛠️ Refactor suggestion
테스트 로직을 완성하세요.
테스트 메서드가 불완전합니다. Calendar 설정 후 실제 Book 인스턴스 생성과 동등성 검증이 필요합니다.
void shouldConsiderBookWithSameTitleAndPublicationDateAsEqual() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2024);
- calendar.set(Calendar.MONTH, 1);
- Calendar.set(Calendar.DAY_OF_MONTH, 1);
+ calendar.set(Calendar.MONTH, 0);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ Book book1 = new Book("같은 제목", calendar.getTime());
+ Book book2 = new Book("같은 제목", calendar.getTime());
+ assertEquals(book1, book2);
+ assertEquals(book1.hashCode(), book2.hashCode());
}🤖 Prompt for AI Agents
In src/test/java/instance/BookTest.java around lines 12 to 19, the test method
shouldConsiderBookWithSameTitleAndPublicationDateAsEqual is incomplete; after
setting the Calendar date, create two Book instances with the same title and
publication date using the Calendar object, then assert their equality using an
appropriate assertion method to complete the test logic.
| public Book clone() { | ||
|
|
||
| } |
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.
clone 메서드 구현을 완성하세요.
clone 메서드가 선언되었지만 구현되지 않았습니다. 컴파일 오류가 발생합니다.
@Override
public Book clone() {
-
+ try {
+ Book cloned = (Book) super.clone();
+ cloned.publishDate = (Date) this.publishDate.clone();
+ return cloned;
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError();
+ }
}📝 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 Book clone() { | |
| } | |
| @Override | |
| public Book clone() { | |
| try { | |
| Book cloned = (Book) super.clone(); | |
| cloned.publishDate = (Date) this.publishDate.clone(); | |
| return cloned; | |
| } catch (CloneNotSupportedException e) { | |
| throw new AssertionError(); | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/main/java/instance/Book.java around lines 59 to 61, the clone method is
declared but not implemented, causing a compilation error. Implement the clone
method to create and return a new Book object that is a copy of the current
instance, ensuring all relevant fields are duplicated appropriately. If the
class implements Cloneable, override the clone method properly; otherwise,
create a new instance manually copying the fields.
| public int compareTo(Book o) { | ||
|
|
||
| return 0; | ||
| } |
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.
🛠️ Refactor suggestion
compareTo 메서드 구현을 완성하세요.
compareTo 메서드가 항상 0을 반환하여 모든 Book 객체가 동일한 순서로 취급됩니다. 학습된 내용에 따르면 publishDate 기준으로 최신순(내림차순) 정렬이 필요합니다.
@Override
public int compareTo(Book o) {
-
- return 0;
+ return o.publishDate.compareTo(this.publishDate);
}📝 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 int compareTo(Book o) { | |
| return 0; | |
| } | |
| @Override | |
| public int compareTo(Book o) { | |
| return o.publishDate.compareTo(this.publishDate); | |
| } |
🤖 Prompt for AI Agents
In src/main/java/instance/Book.java around lines 53 to 56, the compareTo method
currently returns 0, which treats all Book objects as equal. Implement the
compareTo method to compare the publishDate fields of the current Book and the
parameter Book, returning a negative value if the current Book is published
after the parameter (to achieve descending order), zero if equal, and a positive
value if before. Use the appropriate date comparison method to ensure sorting by
publishDate in descending order.
250701_19_최아인
📝 과제 정보
📋 체크리스트
🔍 구현 방법
📷 실행 결과
🚨 어려웠던 점
💡 배운 점
❓ 질문 사항
📚 참고 자료
🔄 자체 평가 & 회고
...