-
Notifications
You must be signed in to change notification settings - Fork 74
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
[자동차 경주] 강동안 미션 제출합니다. #80
Conversation
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.
고생하셨습니다~! 👍
import java.util.Arrays; | ||
|
||
public class Game { | ||
Competition game = new Competition(); |
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.
Game
클래스 내에서 Competition
클래스의 객체 이름이 game
인건 뭔가 헷갈리는것 같아요!
Racing
같은 네이밍은 어떨까요??
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.
그런 방향으로 생각도 해봐야겠네요. 비슷한 기능들이 좀 클래스화되어있으니 좀 더 이름 짓기가 어려워지는거 같아요. 다음에는 좀 더 구체적으로 적어보겠습니다!
|
||
joinGame(carNames); | ||
|
||
System.out.println("\n실행 결과"); |
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.
이것도 ResultView
의 메서드로 뺄 수 있을것 같아요!
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.
그러게요! 이제와서 생각이 나네요.
joinGame(carNames); | ||
|
||
System.out.println("\n실행 결과"); | ||
for (int i=0;i < gameTime;i++){ |
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.
파일 전체적으로 ctrl
+ alt
+ L
단축키를 사용하면 자동 줄맞춤이 되는데 한번 해보면 좋을 것 같아용
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.
감사합니다!
ResultView.printRound(game.getCars()); | ||
} | ||
|
||
ArrayList<Car> winners = game.getWinners(); |
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.
업캐스팅
에 대해서 한번 알아보면 좋을 것 같아요!
다형성과 관련이 있답니다
자료 : https://bibi6666667.tistory.com/236
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.
공부할 때 이부분은 빼놓고 선언 해주는 것만 생각하고있었나봐요. 피드백 주셔서 감사합니다!
Game game = new Game(); | ||
|
||
game.game(); |
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.
이 정도는 개행 안해도 될것 같아요 👍
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.
넵! 😄
public void runCompetition(int value){ | ||
for (Car car : cars){ | ||
car.moveCar(value); | ||
} | ||
} |
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.
테스트를 위한 메서드가 객체 내에 존재하는건 좋지 않은것 같아요!
생성자를 통해 전달하는 방식은 어떨까요??
for (Car car : cars){ | ||
positionList.add(car.getPosition()); | ||
} |
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.
cars
를 많이 사용하는 것 같은데 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.
오 그럼 CarController로 네이밍 후 객체를 다루는 클래스로 분리해주는거도 괜찮은거 같아요!
배운점
MVC구조를 보며 이게 백엔드와 프론트엔드의 구조이고 그 징검다리 역할을 깔끔하게 잘 해주어야겠다는 생각이 들었다.
좀 더 객체지향적인 코드를 짤 수 있게 된 거 같다. 아직 자바가 익숙하지 않아서 그런지 배우는 시간이 좀 더딘 느낌도 있다.
아쉬웠던 점
이번 과제에서 스트림과 람다식 이용하는 법을 좀 알게되어 과하게 쓴 거 같다. 가독성이 좋지않아보인다.
ArrayList 에 좀 과하게 의존한 듯 싶다. 더 깔끔한 코드작성을 하고 싶었는데, 여러번 나온 거 같아 아쉽다.
클래스명이 좀 직관적이지 않은거같다. 근데 이름짓기가 세상에서 제일 어렵다.
처음에 Car class에 이동하는 로직을 넣었는데, 그걸 넣는거보단 외부의 값에 의존하게 하는게 나은거 같다. 그래서 고쳤다. 근데 아직도 맞나 모르겠다.
private을 좀 썼는데 어디에 써도 되고 어디에 써야하는지 확신이 들지 않았다. 좀 찾아보니 final도 쓰던데 그 final도 같이 잘 써보고싶다.
또한 지금은 좀 아쉽지만, nextInt를 오버라이딩하는 방법도 있었는데, 당시엔 생각이 나지 않아서 작성하지 않았다.
너무 실행 없이 코드만 치고 나중에 확인했을때 개판인 걸 봐선 좀 더 확인을 하면서 코드를 짜는 것이 좋아보인다.
궁금했던 점
어디에다가 final을 쓰는지 궁금하고, 인터페이스에 대한 이야기도 들었는데 어떻게 사용하는지 감이 안잡혔습니다.
이번 조건에 들여쓰기 2(공백8 X)칸이 금지되어 있었는데, 실제로 이렇게까지 들여쓰기를 안하는지 궁금합니다.
메서드의 순서를 배치할 때, 서로의 기준이 있는지 궁금합니다.
감사합니다.