package com.exam;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Scanner;
public class PTest {
private List pokerList = new ArrayList();//创建扑克List
private List peopleList = new ArrayList();//创建玩家List
public void creatcard(){
String[] num={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
String[] type={"红桃","方块","梅花","黑桃"};
String[] other={"大王","小王"};
int sum=0;//统计总牌数量
int sum1=0;//每四个换一行数量
System.out.println("----创建扑克牌----");
for(int i=0;i0) {
for (People1 people : peopleList) {
System.out.println("---玩家"+people.getName()+"-拿牌");
people.cards.add(pokerList.get(j));
j++;
sum++;
if(sum==54){
break;
}
}
i--;
}
System.out.println("------发牌结束!-------");
System.out.println("玩家各自的手牌为:");
for (People1 people : peopleList) {
System.out.println(people.getName()+":"+people.cards.toString());
}}
public static void main(String[] args) {
// TODO Auto-generated method stub
PTest go = new PTest();
go.creatcard();
go.upsetPoker();
go.createPeople();
go.issuePoker();
System.out.println("");
}
} package com.exam;
public class Card {
private String num;
private String type;
private String other;
public Card(String num,String type,String other){
this.num=num;
this.type=type;
this.other=other;
}
public String getOther() {
return other;
}
public void setOther(String other) {
this.other = other;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return num + type + other;
}
}package com.exam;
import java.util.ArrayList;
import java.util.List;
public class People1 {
private Integer id;
private String name;
public List cards;
public People1 (Integer id, String name) {
super();
this.id = id;
this.name = name;
this.cards = new ArrayList();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} 小测试一枚,java基础看了好多遍,要泪崩了!!!!



