第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

做作業(yè)了做作業(yè)了

package?collection_map_demo.Game;

import?java.util.ArrayList;
import?java.util.Collections;
import?java.util.List;

public?class?Player?{
????public?String?id;
????public?String?name;
????public?List?pokers;
????public?Player(String?id,?String?name){
????????this.id?=?id;
????????this.name?=?name;
????????this.pokers?=?new?ArrayList();
????}
????public?void?dropPokers(){
????????pokers.clear();
????}
????public?Poker?selectMaxPoker(){
????????Collections.sort(pokers);
????????return?(Poker)?pokers.get(0);
????}
}



package?collection_map_demo.Game;

import?java.util.Arrays;
import?java.util.Collections;
import?java.util.List;

public?class?Poker?implements?Comparable<Poker>?{
????public?String?point;
????public?String?color;
????public?Poker(String?point,String?color){
????????this.point?=?point;
????????this.color?=?color;
????}

????public?Poker()?{

????}

????@Override
????public?int?compareTo(Poker?o)?{
????????//比當(dāng)前的小返回正整數(shù)
????????//比當(dāng)前的大返回副整數(shù)
????????//相等返回0
????????if(this.point.compareTo(o.point)?==?0)?{
????????????return?this.color.compareTo(o.color);
????????}else{
????????????return?this.point.compareTo(o.point);
????????}
????}
}



package?collection_map_demo.Game;

import?java.util.*;

public?class?PokerGame?{
????private?String[]?pointsToSelect;
????private?String[]?colorsToSelect;
????private?static?List<Poker>?combination;
????public?List<Player>?players;
????private?Scanner?scanner;
????public?PokerGame(){
????????this.scanner?=?new?Scanner(System.in);
????????this.players?=?new?ArrayList<Player>();
????????this.pointsToSelect?=?new?String[]{"1",?"2",?"3",?"4",?"5",?"6",?"7",?"8",?"9",?"10",?"J",?"Q",?"K",?"A"};
????????this.colorsToSelect?=?new?String[]{"黑桃",?"紅桃",?"梅花",?"方片"};
????????this.combination?=?new?ArrayList<Poker>();
????}
????public?static?void?main(String[]?args)?{
????????PokerGame?pockerGame?=?new?PokerGame();
????????pockerGame.createPokers();
????????pockerGame.intermingle(combination);
????????pockerGame.createPlayer();
????????pockerGame.startGame();
????}
????public?void?createPokers(){
????????for(String?color?:?colorsToSelect){
????????????for(String?point?:?pointsToSelect){
????????????????Poker?poker?=?new?Poker(point,color);
????????????????System.out.println(poker.color?+?poker.point);
????????????????combination.add(poker);
????????????}
????????}
????}
????public?void?intermingle(List<Poker>?pokers){
????????Collections.shuffle(pokers);
????}
????public?void?createPlayer(){
????????int?i?=?1;
????????while?(i?<?3){
????????????System.out.println("請(qǐng)輸入玩家"?+?i?+?"ID");
????????????String?id?=?scanner.next();
????????????System.out.println("請(qǐng)輸入玩家"?+?i?+"姓名");
????????????String?name?=?scanner.next();
????????????Player?player?=?new?Player(id,name);
????????????System.out.println(player.id?+?player.name);
????????????players.add(player);
????????????i++;
????????}
????????Integer?player_num?=?players.size();
????????System.out.println("玩家組有"?+?player_num?+?"名玩家");
????????for(Player?player?:?players){
????????????System.out.println("玩家"?+?player.id?+?player.name);
????????}
????}
????public?void?startGame(){
????????System.out.println("發(fā)牌");
????????Player?player1?=?players.get(0);
????????Player?player2=?players.get(1);
????????int?i?=?1;
????????while?(?i?<=?4){
????????????Poker?poker?=?combination.get(i);
????????????if(?i?%?2?!=?0){
????????????????//發(fā)給玩家1
????????????????player1.pokers.add(poker);
????????????}else{
????????????????//發(fā)給玩家2
????????????????player2.pokers.add(poker);
????????????}
????????????i++;
????????}
????????System.out.println("玩家1?手牌");
????????for(Object?poker?:?player1.pokers){
????????????Poker?new_poker?=?(Poker)?poker;
????????????System.out.println(new_poker.point?+?new_poker.color);
????????}
????????System.out.println("玩家2?手牌");
????????for(Object?poker?:?player2.pokers){
????????????Poker?new_poker?=?(Poker)?poker;
????????????System.out.println(new_poker.point?+?new_poker.color);
????????}
????????Poker?player_1_max?=?player1.selectMaxPoker();
????????Poker?player_2_max?=?player2.selectMaxPoker();
????????if(player_1_max.point.compareTo(player_2_max.point)?==?0){
????????????if(player_1_max.color.compareTo(player_2_max.color)?<?0){
????????????????System.out.println("玩家?2?贏");
????????????}else{
????????????????System.out.println("玩家?1?贏");
????????????}
????????}else?if(player_1_max.point.compareTo(player_2_max.point)?<?0){
????????????System.out.println("玩家?2?贏");
????????}else{
????????????System.out.println("玩家?1?贏");
????????}
????????player1.dropPokers();
????????player2.dropPokers();
????}
}


正在回答

1 回答

我仿照了你的代碼,為什么輸入玩家ID的信息是跟著撲克牌后面的


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Java入門第三季
  • 參與學(xué)習(xí)       409764    人
  • 解答問(wèn)題       4543    個(gè)

Java中你必須懂得常用技能,不容錯(cuò)過(guò)的精彩,快來(lái)加入吧

進(jìn)入課程

做作業(yè)了做作業(yè)了

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)