package com.company;
import java.util.*;
public class cards {
private List<card> cardList = new ArrayList<>();
private String[] colors = new String[]{"红桃","黑桃","方片","草花"};
public cards(){}
public void init(){
for (int i = 0;i < 4;i++){
for (int j = 1;j < 14;j++){
card card = new card();
card.setColor(colors[i]);
card.setValue(j);
cardList.add(card);
}
}
}
public void print(){
for (int j = 0;j < cardList.size();j++){
if (j %13 == 0){
System.out.println();
}
System.out.print(cardList.get(j).getColor()+cardList.get(j).getValue()+" ");
}
}
public void xipai(){
Collections.shuffle(cardList);
}
public List fapai(){
List<card> cardList1 = new ArrayList<>();
for (int i = 0;i < 5;i++){
Random random = new Random();
int index = random.nextInt(cardList.size());
cardList1.add(cardList.get(index));
}
return cardList1;
}
public void print(List<card> cardList1){
for (int j = 0;j < cardList1.size();j++){
System.out.print(cardList1.get(j).getColor()+cardList1.get(j).getValue()+" ");
}
}
}
package com.company;
public class card {
private String color;
private int value;
public card(){}
public card(String color,int value){
this.color = color;
this.value = value;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
package com.company;
public class card {
private String color;
private int value;
public card(){}
public card(String color,int value){
this.color = color;
this.value = value;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
package com.company;
public class testcards {
public static void main(String[] args) {
cards cards = new cards();
cards.init();
cards.print();
}
}
扑克牌
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...