本文整理汇总了Java中java.util.NavigableMap.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableMap.Entry方法的具体用法?Java NavigableMap.Entry怎么用?Java NavigableMap.Entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.NavigableMap
的用法示例。
在下文中一共展示了NavigableMap.Entry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineFirstPlayer
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Determines the player who should be play first, according to the Scrabble rules
*
* @param bag The bag of the Scrabble game
* @param players The players of the Scrabble game
*
* @return the player who should play first
* @throws EmptyBagException if the bag is empty
*/
protected PlayerInterface determineFirstPlayer(BagInterface bag, List<PlayerInterface> players) throws EmptyBagException {
NavigableMap<LetterInterface, PlayerInterface> playersDrawing = new TreeMap<>((o1, o2) -> o1.toString().compareTo(o2.toString()));
for (PlayerInterface player : players) {
playersDrawing.put(bag.drawLetter(), player);
}
for (NavigableMap.Entry<LetterInterface, PlayerInterface> playerDrawing : playersDrawing.entrySet()) {
bag.putBackLetter(playerDrawing.getKey());
}
return playersDrawing.firstEntry().getValue();
}