class Deck{
int suit;
int rank;
Deck(){
this.suit = 0;
this.rank = 0;
} Deck(int suit, int rank){
this.suit = suit;
this.rank = rank;
}
public static void main(String[] args){
Deck threeofClubs = new Deck(0,3);
//printDeck(threeofClubs);
/*
Deck c1 = new Card(1,11);
Deck c2 = new Card(1,11);
if (sameCard(c1,c2))
System.out.println("c1 and c2 are the same card");
*/
//Card[] deck = new Card[52];
//System.out.println(deck[2].rank);
//System.out.println(deck[2]);
}
public static void printCard(Deck c){
String[] suits = {"Clubs","Diamonds","Hearts",
"Spades"};
String[] ranks = {"narf", "Ace", "2", "3", "4" ,
"5", "6" , "7" , "8" ,
"9" , "10" , "Jack" ,
"Queen" , "King" };
System.out.println(ranks[c.rank] + " of " + suits[c.suit]);
}
public static boolean sameCard(Deck c1,Deck c2){
return (c1.suit == c2.suit && c1.rank == c2.rank);
}
public static int compareCard(Deck c1,Deck c2){
if (c1.suit > c2.suit) return 1;
if (c1.suit < c2.suit) return -1;
if (c1.rank > c2.rank) return 1;
if (c1.rank > c2.rank) return -1;
return 0;
}
}/*1) 成员变量改为扑克牌数组cards;
2) 构建器Deck()功能为顺序生成一副纸牌;
3) 用printDeck方法打印一副扑克牌;*/
int suit;
int rank;
Deck(){
this.suit = 0;
this.rank = 0;
} Deck(int suit, int rank){
this.suit = suit;
this.rank = rank;
}
public static void main(String[] args){
Deck threeofClubs = new Deck(0,3);
//printDeck(threeofClubs);
/*
Deck c1 = new Card(1,11);
Deck c2 = new Card(1,11);
if (sameCard(c1,c2))
System.out.println("c1 and c2 are the same card");
*/
//Card[] deck = new Card[52];
//System.out.println(deck[2].rank);
//System.out.println(deck[2]);
}
public static void printCard(Deck c){
String[] suits = {"Clubs","Diamonds","Hearts",
"Spades"};
String[] ranks = {"narf", "Ace", "2", "3", "4" ,
"5", "6" , "7" , "8" ,
"9" , "10" , "Jack" ,
"Queen" , "King" };
System.out.println(ranks[c.rank] + " of " + suits[c.suit]);
}
public static boolean sameCard(Deck c1,Deck c2){
return (c1.suit == c2.suit && c1.rank == c2.rank);
}
public static int compareCard(Deck c1,Deck c2){
if (c1.suit > c2.suit) return 1;
if (c1.suit < c2.suit) return -1;
if (c1.rank > c2.rank) return 1;
if (c1.rank > c2.rank) return -1;
return 0;
}
}/*1) 成员变量改为扑克牌数组cards;
2) 构建器Deck()功能为顺序生成一副纸牌;
3) 用printDeck方法打印一副扑克牌;*/
谁能帮我?