-
Notifications
You must be signed in to change notification settings - Fork 23
5주차 과제입니다. #96
base: Sinya47
Are you sure you want to change the base?
5주차 과제입니다. #96
Conversation
return speed; | ||
} | ||
|
||
public int getMove() { |
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.
사용하지 않는 getter는 삭제해주세요.
return move; | ||
} | ||
|
||
public void setMove(int move) { |
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.
사용하지 않는 setter는 삭제해주세요.
} | ||
|
||
class SuperCar extends Car { | ||
private long seed = System.currentTimeMillis(); |
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.
seed는 random 객체를 초기화할때 단 한번만 사용되므로, 클래스의 멤버일 필요가 없습니다. 생성자 내부에서 로컬 변수로 선언한 뒤 Random을 만들때만 사용하면 됩니다.
class SuperCar extends Car { | ||
private long seed = System.currentTimeMillis(); | ||
private Random random = new Random(seed); | ||
private Random random2 = new Random(seed); |
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.
random의 seed가 현재시간이므로 객체를 하나만 만들어서 사용해도 됩니다. 2개를 만드는건 비효율적입니다.
protected int move; | ||
protected int second; | ||
|
||
public Car() { |
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.
기본생성자를 만들지 않고 super car 클래스에서 바로 super로 car의 생성자를 호출해주세요
코멘트 확인 후 수정 바랍니다. 이해되지 않는 부분이 있다면 언제든 질문 해주세요~ |
No description provided.