-
Notifications
You must be signed in to change notification settings - Fork 3
Jyj1289 #1
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: jyj1289
Are you sure you want to change the base?
Jyj1289 #1
Conversation
src/main/java/Attacker.java
Outdated
|
|
||
| print(getScore()); | ||
|
|
||
| return 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.
항상 true가 반환 된다면 그냥 void함수가 좋지 않을까요?
| public boolean block(int shoot){ | ||
| Random random = new Random(); | ||
| int blockShoot = random.nextInt(5) + 3; | ||
| if (shoot >= 2 && shoot <= 7 && keep_count > 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.
keep_count가 왜 필요한가요?
| keep_count -= 1; | ||
| return shoot != blockShoot; | ||
| } | ||
| if (shoot >= 2 && shoot <= 8){ |
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.
이 코드의 이유가 있을까요?
|
|
||
| boolean shootBool = keeper.block(shoot); | ||
|
|
||
| if (shootBool){ |
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/Soccer.java
Outdated
| public void print(int score){ | ||
| for(int i = 0; i < score; i++){ | ||
| System.out.print("-"); | ||
| } | ||
| } |
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[] names = inputNames("공격수"); | ||
| Attacker attacker1 = new Attacker(names[0]); | ||
| Attacker attacker2 = new Attacker(names[1]); | ||
|
|
||
| names = inputNames("미드필더"); | ||
| Midfielder midfielder1 = new Midfielder(names[0]); | ||
| Midfielder midfielder2 = new Midfielder(names[1]); | ||
|
|
||
| names = inputNames("골키퍼"); | ||
| Keeper keeper = new Keeper(names[0]); | ||
|
|
||
| int matchPoint = inputMatchPoint(); | ||
| boolean bool = true; | ||
|
|
||
| int count = 1; | ||
|
|
||
| Soccer[] soccers = new Soccer[] {attacker1, attacker2, midfielder1, midfielder2}; |
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 형태면 더 좋을것 같습니다
| System.out.printf("\n%d번째 슈팅결과", count); | ||
| printResult(soccers, keeper); | ||
| count++; | ||
| bool = check(attacker1, attacker2, midfielder1, midfielder2, matchPoint); |
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로 받아보세요!
src/main/java/Soccer.java
Outdated
| @@ -0,0 +1,27 @@ | |||
| public abstract class Soccer{ | |||
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.
Soccer라는 네이밍에 대해서 고민해봐야할 것 같아요. Soccer가 뭐죠?
src/main/java/Midfielder.java
Outdated
| goal(); | ||
| } | ||
|
|
||
| print(getScore()); |
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.
공격수도 그렇고 print(getScore())라는 로직을 가지고 있는데, printScore()메서드를 만드는 것이 더 효율적이고, 깔끔한 것 같습니다.
src/main/java/Midfielder.java
Outdated
|
|
||
| print(getScore()); | ||
|
|
||
| return 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.
의미 없는 리턴은 없어야합니다.
src/main/java/Keeper.java
Outdated
| @@ -0,0 +1,28 @@ | |||
| import java.util.Random; | |||
|
|
|||
| public class Keeper extends Soccer{ | |||
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.
굳이 Keeper가 Soccer를 상속받을 필요는 없습니다.
src/main/java/Keeper.java
Outdated
| public boolean shoot(Keeper keeper){ | ||
| return false; | ||
| } |
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 javax.accessibility.AccessibleTable; | ||
| import java.util.Scanner; | ||
|
|
||
| public class SoccerGameApplication { |
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.
이 클래스의 책임이 너무 많은 것 같아요. 작게는 문자를 출력하는 것부터, 크게는 핵심 로직까지 다 이 클래스가 책임지고 있습니다.
| return matchPoint; | ||
| } | ||
|
|
||
| static boolean check(Attacker attacker1, Attacker attacker2, Midfielder midfielder1, Midfielder midfielder2 ,int matchPoint){ |
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.
Player배열을 사용하는 것이 어떨까요?
| isNotGameDone = check(attacker1, matchPoint) && check(attacker2, matchPoint) | ||
| && check(midfielder1, matchPoint) && check(midfielder2, matchPoint); |
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로 바꿔서 메소드 분리하면 좋을 것 같습니다
| Scanner sc = new Scanner(System.in); | ||
| System.out.print("매치포인트를 입력하세요 : "); | ||
|
|
||
| int matchPoint = sc.nextInt(); |
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.
matchPoint선언한 이유가 있나요?
전유진 과제 제출합니다