-
Notifications
You must be signed in to change notification settings - Fork 55
2주차 과제 제출합니다 #56
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
base: main
Are you sure you want to change the base?
2주차 과제 제출합니다 #56
Conversation
feat: 자동차 작업 feat: 이동 작업 feat: 스캐너 feat: 우승자 작업
feat: 자동차 작업 feat: 이동 작업 feat: 스캐너 feat: 우승자 작업.
feat: 자동차 작업 feat: 이동 작업 feat: 스캐너 feat: 우승자 작업.
feat: 자동차 작업 feat: 이동 작업 feat: 스캐너 feat: 우승자 작업
feat: 자동차 작업 feat: 이동 작업 feat: 스캐너 feat: 우승자 작업.
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.
이번 주차 코드 열심히 작성해주셨네요.
저번에 보내드린 강의는 참고해보셨을까요?! 자바 기초 문법부터해서 차근차근 한 번 밟아나가보면 좋을 거 같아요. 코멘트와 블로그 주소들도 적어놓았으니, 참고하시고 공부하시면 좋겠습니다.
고생하셨어요~
추가적으로, PR의 제목은 [신현섭_BackEnd] 2주차 과제 제출합니다. 처럼 다른 분들과 통일성있게 제출해주시면 감사하겠습니다~
커밋과 관련된 부분은, 저렇게 @hyunseop06
feat: 메인 작업
feat: 자동차 작업
feat: 이동 작업
feat: 스캐너
feat: 우승자 작업 -> 처럼 한 번에 적어주시는 것보다, 한 작업에 하나씩, feat: CarCenter 클래스 구현처럼 올려주시면 더 가독성있고, 작업 단위로 분리되어서 보기 좋답니다.
| public class Application { | ||
| public static void main(String[] args) { | ||
| // TODO: 프로그램 구현 | ||
| public static <string, try1> void main(String[] args) { |
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.
자바에서 메인은 제공하는 psvm(public static void main(String[] args))로 서술해주셔야해요!
psvm은 무엇일까?
| public static <string, try1> void main(String[] args) { | ||
| Scanner in = null; | ||
| System.out.println("자동차 이름을 적으시오 : "); | ||
| string cars = (string) in.next(); |
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.
자바에서 String은 소문자로 적으시면 안돼요! 대소문자 구분이 확실해야 한답니다
| string cars = (string) in.next(); | |
| String cars = (string) in.next(); |
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.
- (string)으로 캐스팅을 진행하신 이유가 있을까요?
| public static void main(String[] args) { | ||
| // TODO: 프로그램 구현 | ||
| public static <string, try1> void main(String[] args) { | ||
| Scanner in = null; |
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.
스캐너를 이렇게 작성하시면 NPE(NullPointerException)이 발생해요!
자바 Scanner 사용법
원하시는 대로 서술하시려면, 아래의 방법처럼 해주셔야 한답니다. 새로운 Scanner 객체를 생성하셔야해요.
| Scanner in = null; | |
| Scanner in = new Scanner(system.in); |
| string cars3 = (string) in.next(); | ||
|
|
||
| System.out.println("이동 횟수를 적으시오 : "); | ||
| try1 try1 = (try1) in.next(); |
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.
try1이라는 변수를 통해서 "정수"를 받고 싶으셨던 거 같아요.
Int를 받고 싶으시다면 아래처럼 선언해야해요! 이 관련된 부분도 위의 스캐너 블로그를 참고하시면 알기 좋을 거 같아요.
| try1 try1 = (try1) in.next(); | |
| int tryCount = in.nextInt(); // |
| try1 try1 = (try1) in.next(); | ||
| } | ||
| } | ||
| }r |
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.
r은 지워주셔야해요!!
| import java.util.Random; | ||
| import java.util.Scanner; | ||
|
|
||
| public class carcenter { |
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.Scanner; | ||
|
|
||
| public class carcenter { | ||
| private Scanner in; |
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.
위와 동일하게 Scanner를 선언해주셨네요. 이렇게 선언하면 어떤 문제가 생길까요?
위에 작성해드린 코드를 참고해보시고, 어떻게 수정하면 좋을지 생각해보세요!
|
|
||
| public class scanner { | ||
| public static void main(String[] args) { | ||
| Scanner scanner = new Scanner(System.in); |
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.
Scanner 클래스는 이렇게 만들어주시지 않으셔도, 자바에서 제공하는 클래스에요!
이 클래스는 삭제하셔도 될 거 같아요.
| @@ -0,0 +1,4 @@ | |||
| package racingcar; | |||
|
|
|||
| public class winner { | |||
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 class run { | ||
| public static void main(String[] args) throws IOException { | ||
| System.out.println("-" + (int)(Math.random() * 9)); |
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.
이 코드에서 의도하시고 싶으셨던 부분은 자동차의 움직임을 -로 나타내는 것이셨던 것 같은데, 이렇게 코드를 실행하면 코드가 어떻게 출력될까요?
아마.. "-3"이런 식으로 출력될 것 같아요🤔 -> 어렵다면, 다른 분들의 코드를 참고해보셔도 좋아요.
No description provided.