Poker类,代码贴上
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Poker {
public static List
List
list.add("大王");
list.add("小王");
String[] type = {"红桃","黑桃","梅花","方块"};
String[] value = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
for (String t : type) {
for (String v : value) {
list.add(t+v);
}
}
return list;
}
}
随即抽牌类,代码贴上
import java.util.List;
import java.util.Random;
public class RandomPoker {
public static String getRandomPoker(){
List
int pokerIndex = new Random().nextInt(pokerList.size());
String poker = pokerList.get(pokerIndex-1);
return poker;
}
//写个main方法测试一下
public static void main(String[] args) {
System.out.println(getRandomPoker());
}
}
用继承啊,2个类是1:牌类,2:扑克牌类。扑克牌类继承牌类,再用random随机抽取一张。
又不具体
学习了,感谢三楼!