参考斗地主的游戏规则,完成一个发牌的功能
(54张牌,考虑点数,花色;三名玩家,其中地主比其他玩家多3张牌)
(1) 牌类(花色,点数)
(2) 玩家类(id,名字,是否地主,牌集合)
一.牌类
//导包
import java.util.Objects;
public class Card {
// 牌面值
private String name;
// 花色
private String flower;
public Card() {
}
public Card(String name, String flower) {
super();
this.name = name;
this.flower = flower;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFlower() {
return flower;
}
public void setFlower(String flower) {
this.flower = flower;
}
@Override
public String toString() {
if(Objects.nonNull(flower)){
//如果牌有花色,显示花色和牌面值信息
return flower + name;
}else{
return name ;
}
}
}
二.玩家类
import java.util.ArrayList;
public class Player {
//玩家id
private int id;
//姓名
private String name;
// 是否地主
private boolean boss;
//玩家获得的牌集合
private ArrayList<Card> cards = new ArrayList<>();
public Player() {
}
public Player(int id,