Skip to content

Commit

Permalink
[#6] refactor: Change some method's access modifier from private to p…
Browse files Browse the repository at this point in the history
…ublic

1. acquireAttackTeam, acuqireDefenseTeam, acqurireCurrentInning() 메소드의 접근제어자를 public으로 변경
2. team id와 등번호로 BattingHistory를 반환해주는 메소드 추가
  • Loading branch information
isaac56 committed May 7, 2021
1 parent 91025c8 commit 75f68cc
Showing 1 changed file with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import team9.baseball.domain.aggregate.team.Team;
import team9.baseball.domain.enums.Halves;
import team9.baseball.domain.enums.PitchResult;
import team9.baseball.exception.NotFoundException;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -127,6 +128,34 @@ public int getTotalScore(Halves halves) {
return inningMap.values().stream().filter(x -> x.getHalves() == halves).mapToInt(x -> x.getScore()).sum();
}

public Team acquireAttackTeam(Team awayTeam, Team homeTeam) {
if (currentHalves == Halves.TOP) {
return awayTeam;
}
return homeTeam;
}

public Team acquireDefenseTeam(Team awayTeam, Team homeTeam) {
if (currentHalves == Halves.TOP) {
return homeTeam;
}
return awayTeam;
}

public Inning acquireCurrentInning() {
String currentInningKey = Inning.acquireKeyInGame(currentInning, currentHalves);
return inningMap.get(currentInningKey);
}

public BattingHistory acquireBattingHistory(int batterTeamId, int batterUniformNumber) {
String key = BattingHistory.acquireKeyInGame(batterTeamId, batterUniformNumber);
if (!battingHistoryMap.containsKey(key)) {
throw new NotFoundException(String.format("%d번 게임방에 %d팀 %d 번호 선수에 대한 기록이 없습니다.",
this.id, batterTeamId, batterUniformNumber));
}
return battingHistoryMap.get(key);
}

private void proceedOut(Team awayTeam, Team homeTeam) {
//아웃 카운트 증가
this.outCount++;
Expand Down Expand Up @@ -203,25 +232,6 @@ private void sendBatterOnPlate(Team attackTeam) {
battingHistory.plusAppear();
}

private Team acquireAttackTeam(Team awayTeam, Team homeTeam) {
if (currentHalves == Halves.TOP) {
return awayTeam;
}
return homeTeam;
}

private Team acquireDefenseTeam(Team awayTeam, Team homeTeam) {
if (currentHalves == Halves.TOP) {
return homeTeam;
}
return awayTeam;
}

private Inning acquireCurrentInning() {
String currentInningKey = Inning.acquireKeyInGame(currentInning, currentHalves);
return inningMap.get(currentInningKey);
}

private int acquireAttackTeamId() {
if (currentHalves == Halves.TOP) {
return awayTeamId;
Expand Down

0 comments on commit 75f68cc

Please sign in to comment.