Skip to content

Conversation

@taekyun0219
Copy link

@taekyun0219 taekyun0219 commented Jul 6, 2024

클래스별로 나눠서 다시 리펙터링 했습니다!

d11210920

This comment was marked as off-topic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 기능이 한 클래스에 집중되어 있습니다. 객체지향적 설계를 생각해보고 관심사의 분리를 적용해보세요~~!!
야구게임을 진행할때, 필요한 객체, 기능들을 생각해보면 리팩토링 가능할 것 같습니다!!

import java.util.List;

public class Computer {
private List<Integer> com;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수명을 좀더 명확하게 지어주세요!! 길어도 되니 어떤 용도로 쓰이는 변순지 명확히 알려주세요

while(true){
System.out.println("숫자 야구 게임을 시작합니다.");
computer.Random();
while(true){
Copy link
Collaborator

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])){
Copy link
Collaborator

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();
Copy link
Collaborator

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){
Copy link
Collaborator

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만 사용할 수 있습니다!!

import java.util.List;

public class Go {
public static String Check(List<Integer> computer, int[] input){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static 함수를 사용한 이유가 있나요?? 있다면 어떤 이유인가요?? static함수를 사용하는 경우와 특징을 공부해보세요~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants