-
Notifications
You must be signed in to change notification settings - Fork 3
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
Lee UI jin #9
base: main
Are you sure you want to change the base?
Lee UI jin #9
Conversation
merge : draw function extract method |
} | ||
const car = new Car(); | ||
export interface TrafficLight{ |
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.
} | |
const car = new Car(); | |
export interface TrafficLight{ | |
} | |
const car = new Car(); | |
export interface TrafficLight{ |
이 해당 문단은 띄어쓰기 필요합니다.
|
||
const CYCLE = [new Red(), new Green(), new Yellow()]; | ||
const updateCarForLight = (current: TrafficLight) => { |
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.
const updateCarForLight = (current: TrafficLight) => { | |
const updateCarForLight = (current: TrafficLight) => { | |
return current.updateCar(); | |
} |
매개 변수는 클래스와 함수가 아닌 인터페이스로 매개변수를 사용하고 있습니다. 왜 인터페이스를 사용 했을까요? 이 부분을 찾아보고 공부를 해보면 어떨까요?
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.
이에 대해 공부해보니 매개변수로 사용하는 것은 그 인터페이스를 따르는 객체들만 매개변수로 할당할 수 있게 해주고
객체들은 인터페이스를 구현해야 하므로 객체마다 .updateCar()의 동작이 다른 경우에도 함수에서 모두 처리할 수 있다는 것을 알았습니다.
Co-authored-by: 안지환 <[email protected]>
요약
Pull Request 체크리스트
TODO
이에 따라 코드가 실행되는 순간에 실행이 결정되는 if 문으로 수정합니다.