码迷,mamicode.com
首页 > 其他好文 > 详细

创建扑克牌测试(一)

时间:2018-03-17 12:57:35      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:Java   List   

1.Main

public class Main {
	/**
	 * 1.面向对象思维(一张扑克)
	 * 抽取共性属性
	 *   花色	int
	 *   牌值	int
	 *   花色符号	String
	 *   牌值符号	String
	 * 抽取共性方法
	 * 
	 * 2.面向对象思维(一副扑克)
	 * 抽取共性属性
	 *   花色数量	int 
	 *   牌的张数	int
	 *   所有牌	List
	 * 抽取共性方法
	 *   创建扑克
	 *   洗牌
	 *   抽取一张
	 *   分组
	 *   排序
	 * 1(多)--对--2(一)
	 * */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
	}
}


2.Apuke(一张扑克)

//一张扑克类
public class Apuke {
	/**
	 * 1.定义属性
	 * */
	private int    color;      // 花色值
	private String colorText;  // 花色符号
	private int    value;      // 牌值
	private String valueText;  // 牌值符号
	
	/**
	 * 2.创建构造方法和setter、getter方法、toString方法
	 * */
	public Apuke(int color, String colorText, int value, String valueText) {
		super();
		this.color = color;
		this.colorText = colorText;
		this.value = value;
		this.valueText = valueText;
	}
	public int getColor() {
		return color;
	}
	public void setColor(int color) {
		this.color = color;
	}
	public String getColorText() {
		return colorText;
	}
	public void setColorText(String colorText) {
		this.colorText = colorText;
	}
	public int getValue() {
		return value;
	}
	public void setValue(int value) {
		this.value = value;
	}
	public String getValueText() {
		return valueText;
	}
	public void setValueText(String valueText) {
		this.valueText = valueText;
	}
	
	@Override
	public String toString() {
		return "Apuke [color=" + color + ", colorText=" + colorText + ", value=" + value + ", valueText=" + valueText
				+ "]";
	}
	
	
}


3.Pukes(一副扑克)

import java.util.List;
// 一副扑克
public class Pukes {
	/**
	 * 3.定义属性
	 * */
	private int         pukesCount;  // 扑克张数
	private int         colorCount;  // 花色数量
	private List<Apuke> aList;       // 扑克牌的集合
	
	/**
	 * 4.创建setter、getter方法、toString方法
	 * */
	
	public int getPukesCount() {
		return pukesCount;
	}

	public void setPukesCount(int pukesCount) {
		this.pukesCount = pukesCount;
	}
	public int getColorCount() {
		return colorCount;
	}
	public void setColorCount(int colorCount) {
		this.colorCount = colorCount;
	}
	public List<Apuke> getaList() {
		return aList;
	}
	public void setaList(List<Apuke> aList) {
		this.aList = aList;
	}

	@Override
	public String toString() {
		return "Pukes [pukesCount=" + pukesCount + ", colorCount=" + colorCount + ", aList=" + aList + "]";
	}
	
	/**
	 * 5.先把业务方法定义出来,可以先搭个架子
	 * */
	// 5.1.创建一副扑克牌的方法
	public List<Apuke> createPuke(){
		return null;
	}
	
	// 5.2.洗牌的方法
	public List<Apuke> shufferPuke(){
		return null;
	}
	
	// 5.3.随机抽取一张扑克
	public Apuke getRandomPuke() {
		return null;
	}
	
	// 5.4.排序所有扑克牌
	public List<Apuke> sortPuke(){
		return null;
	}
	
	// 5.5.分组最后做
	
}




创建扑克牌测试(一)

标签:Java   List   

原文地址:http://blog.51cto.com/13634837/2087868

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!