-
Notifications
You must be signed in to change notification settings - Fork 10
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
[숫자 야구 게임] 이태균 과제 제출합니다. #3
base: main
Are you sure you want to change the base?
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.
모든 기능이 한 클래스에 집중되어 있습니다. 객체지향적 설계를 생각해보고 관심사의 분리를 적용해보세요~~!!
야구게임을 진행할때, 필요한 객체, 기능들을 생각해보면 리팩토링 가능할 것 같습니다!!
src/main/java/baseball/Computer.java
Outdated
import java.util.List; | ||
|
||
public class Computer { | ||
private List<Integer> com; |
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/baseball/Game.java
Outdated
while(true){ | ||
System.out.println("숫자 야구 게임을 시작합니다."); | ||
computer.Random(); | ||
while(true){ |
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.
이 while문을 새로운 메소드로 구분지을수 있을거 같아요!
int ball = 0; | ||
for(int i = 0; i < 3; i++){ | ||
for(int j = 0; j < 3; j++){ | ||
if(computer.get(i).equals(input[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.
List<>에 contains라는 함수가 있습니다 찾아보고 활용해보세요~~!
return Console.readLine(); | ||
} | ||
public int[] getInput(){ | ||
String input = getUserInput(); |
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(ball == 0 && strike == 0){ | ||
return "낫싱"; | ||
} | ||
else if(strike == 0){ |
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문에서 return을 활용하면 else if 대신 if만 사용할 수 있습니다!!
src/main/java/baseball/Go.java
Outdated
import java.util.List; | ||
|
||
public class Go { | ||
public static String Check(List<Integer> computer, int[] input){ |
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.
static 함수를 사용한 이유가 있나요?? 있다면 어떤 이유인가요?? static함수를 사용하는 경우와 특징을 공부해보세요~~
클래스별로 나눠서 다시 리펙터링 했습니다!