java基础高级综合练习题扑克牌

———————–java基础高级综合练习题扑克牌—————–

题目要求:
1.创建一副有序的扑克牌,
2.随机洗牌
3.随机抽取一张牌
4.对扑克牌进行自定义排序
5.对扑克牌按牌色分组

————创建一张牌的类——————-
package cn.tx.poker;
/**
* 一张扑克牌的类
* @作者 李昆鹏
*
*/
public class APoker implements Comparable{

    /**
     * 花色ID
     */
    private int colorId;

    /**
     * 花色
     */
    private String color;

    /**
     * 扑克牌ID
     */
    private int pokerValueId;

    /**
     * 扑克牌
     */
    private String pokerValue;

    public int getColorId() {
        return colorId;
    }

    public void setColorId(int colorId) {
        this.colorId = colorId;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getPokerValueId() {
        return pokerValueId;
    }

    public void setPokerValueId(int pokerValueId) {
        this.pokerValueId = pokerValueId;
    }

    public String getPokerValue() {
        return pokerValue;
    }

    public void setPokerValue(String pokerValue) {
        this.pokerValue = pokerValue;
    }

    public APoker(int colorId, String color, int pokerValueId, String pokerValue) {
        super();
        this.colorId = colorId;
        this.color = color;
        this.pokerValueId = pokerValueId;
        this.pokerValue = pokerValue;
    }

    @Override
    public String toString() {
        return "\n一张扑克牌 [ 扑克牌的种类 =" + color + ","+  " 扑克牌=" + pokerValue + "]";
    }

    @Override
    public int compareTo(APoker o) {
        int val = this.colorId - o.colorId;
        if(val == 0)
            val = this.pokerValueId - o.pokerValueId;
        return val;
    }

}

—————–创建一组牌的类———————
package cn.tx.poker;

import java.util.ArrayList;
import java.util.List;

/**
* 创建一组扑克牌的类
* @作者 李昆鹏
*
*/
public class PokerGroup {

/**
 * 组的颜色ID
 */
private int colorGroupId;

/**
 * 组的颜色
 */
private String colorGroup;

/**
 * 一组扑克牌集合
 */
private List pokerList = new ArrayList();

/**
 * 一组扑克牌的数量
 */
private int pokerGroupCount;

public int getColorGroupId() {
    return colorGroupId;
}

public void setColorGroupId(int colorGroupId) {
    this.colorGroupId = colorGroupId;
}

public String getColorGroup() {
    return colorGroup;
}

public void setColorGroup(String colorGroup) {
    this.colorGroup = colorGroup;
}

public List getPokerList() {
    return pokerList;
}

public void setPokerList(List pokerList) {
    this.pokerList = pokerList;
}

public int getPokerGroupCount() {
    return pokerGroupCount;
}

public void setPokerGroupCount(int pokerGroupCount) {
    this.pokerGroupCount = pokerGroupCount;
}

@Override
public String toString() {
    return "\nPokerGroup [ 一组牌的颜色=" + colorGroup + ", 组中的牌=" + pokerList
            +  "]";
}

public PokerGroup(int colorGroupId, String colorGroup) {
    super();
    this.colorGroupId = colorGroupId;
    this.colorGroup = colorGroup;
}

}

———————–创建一副牌的类———————— <

你可能感兴趣的:(JAVASE,java)