36 lines
764 B
Java
36 lines
764 B
Java
package chapter6.demo64;
|
|
|
|
// Card.java - 扑克牌类
|
|
public class Card implements Comparable<Card> {
|
|
private String color; // 花色
|
|
private String point; // 点数
|
|
private int index; // 编号
|
|
|
|
/**
|
|
* 构造一张扑克牌
|
|
* @param color 花色
|
|
* @param point 点数
|
|
* @param index 编号
|
|
*/
|
|
public Card(String color, String point, int index) {
|
|
this.color = color;
|
|
this.point = point;
|
|
this.index = index;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return color + point;
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Card other) {
|
|
return this.index - other.index;
|
|
}
|
|
|
|
// getter方法
|
|
public int getIndex() {
|
|
return index;
|
|
}
|
|
}
|