-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 각 시도 결과를 가지고 있는 PhaseResult 추가 - 각 PhaseResult는 자동차의 이름을 Key, 이동 결과를 Value로 하는 Map을 가지고 있음 - PhaseResult는 현재 선두의 이름을 List의 형태로 반환하는 메소드를 가지고있음 2. PhaseResult들을 가지고있는 총 게임 결과 GameResult 추가 - 시도 번호로 각 시도 결과를 가져올 수 있음 - 게임 우승자는 마지막 PhaseResult의 선두의 이름을 가져옴 3. ParticipateCars 의 주석은 어떤게 더 보기좋은지 궁금해서 주석 처리하였음
- Loading branch information
Showing
18 changed files
with
266 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package racing.domain; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
|
||
public class PhaseResult { | ||
private final Map<String, Integer> raceResults; | ||
|
||
public PhaseResult(Map<String, Integer> raceResults) { | ||
this.raceResults = raceResults; | ||
} | ||
|
||
public Map<String, Integer> getRaceResults() { | ||
return raceResults; | ||
} | ||
|
||
public List<String> getCurrentLeads() { | ||
int max = raceResults.entrySet().stream() | ||
.mapToInt(Map.Entry::getValue) | ||
.max() | ||
.orElseThrow(IllegalStateException::new); | ||
|
||
return raceResults.entrySet().stream() | ||
.filter(x -> x.getValue() == max) | ||
.map(Map.Entry::getKey) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.