-
Notifications
You must be signed in to change notification settings - Fork 4
Code comment for baseball-game #2
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: master
Are you sure you want to change the base?
Conversation
1. Standard for a method that functions as oneI don't know the standard of a method that functions as one. Also, I don't know if it really exists. But I think it will be helpful to think about the purpose of making a method once again. In other words, what the method does must be clear.
In addition, These are posts on how to write a good method. When I read it, I share a lot of things that I didn't know. He wrote an posting while doing an effective java study, and I think we should do an effective java study, too. 2. The need for class separationEven though it is a small project, the reason why we are finally making this program is to study about java and OOP .. , so I think we should write the class separately. For your information, I implemented the program by creating
3. Initialize using the constructorYes! that's what the constructor does. 4. static approach with class nameThe purpose of code convention is readability, so I think from that point of view, I wrote down my thoughts on your question. I'm studying, too, so there might be some mistakes 😅 |
src/main/java/Classifier.java
Outdated
| void board() { | ||
| while(true) { | ||
| game(); | ||
| System.out.println("������ ���� �����Ϸ��� 1," | ||
| + " �����Ϸ��� 2�� �Է��ϼ��� ."); | ||
| if(sc.nextInt()==2) { | ||
| break; | ||
| } | ||
| } | ||
| } |
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.
게임 진행 여부와 답이 맞는지 판단할 때 do while을 사용해봐도 괜찮을 것 같아. do while을 사용하게 되면 따로 if문 처리 없이 while문의 조건을 통해 제어할 수 있으니까 😉
do {
game();
System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요 .");
} while(sc.nextInt()==1)
| RandomNumber(){ | ||
| this.number = ((int)(Math.random()*9)+1)*100 | ||
| +((int)(Math.random()*9)+1)*10 | ||
| +((int)(Math.random()*9)+1); | ||
| // System.out.println("���� ���� ="+number); | ||
| } |
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자리 수 라는 조건이 있는데, 이 코드는 난수를 생성할 때 중복된 수를 제외하는 처리가 안되어있음!
src/main/java/Classifier.java
Outdated
| } | ||
|
|
||
| boolean judge() { | ||
| int i=0,j=0,n,un; //i�� ��Ʈ����ũ, j�� �� |
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.
변수가 무엇을 의미하는지 주석보다는 이름을 통해 알 수 있으면 좋을 것 같아
src/main/java/Classifier.java
Outdated
| //ù��° �ڸ� | ||
| n = number/100; | ||
| un = userNumber/100; | ||
| if(stringNumber.contains(un+"")) |
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.
if 안의 내용이 한 줄이어도 가독성을 위해 { } 로 묶어주면 좋을 것 같음
|
|
[Code feedback]
모두 반영해 commit, push 했습니다! |
|
It's works but that's all
i really concerned about this 3.
separate the method
: once method, once function but what's standard?
also i made all of code into just one class because tiny project size. is it okay?
using the constructor
: before the game i want to define the initial setting(like init())
so is it okay to definition by constructor?
class difinition with static
some java convention say don't use the object when i call the class(static) parameter, class method.
instead of using object, use class name
so is it applied to all of case?