Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

5주차 과제입니다. #96

Open
wants to merge 1 commit into
base: Sinya47
Choose a base branch
from

Conversation

Sinya47
Copy link

@Sinya47 Sinya47 commented May 23, 2023

No description provided.

return speed;
}

public int getMove() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는 getter는 삭제해주세요.

return move;
}

public void setMove(int move) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는 setter는 삭제해주세요.

}

class SuperCar extends Car {
private long seed = System.currentTimeMillis();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seed는 random 객체를 초기화할때 단 한번만 사용되므로, 클래스의 멤버일 필요가 없습니다. 생성자 내부에서 로컬 변수로 선언한 뒤 Random을 만들때만 사용하면 됩니다.

class SuperCar extends Car {
private long seed = System.currentTimeMillis();
private Random random = new Random(seed);
private Random random2 = new Random(seed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random의 seed가 현재시간이므로 객체를 하나만 만들어서 사용해도 됩니다. 2개를 만드는건 비효율적입니다.

protected int move;
protected int second;

public Car() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기본생성자를 만들지 않고 super car 클래스에서 바로 super로 car의 생성자를 호출해주세요

@k0000k
Copy link
Member

k0000k commented May 25, 2023

코멘트 확인 후 수정 바랍니다. 이해되지 않는 부분이 있다면 언제든 질문 해주세요~

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants