阅读以下说明和Java程序,填补代码中的空缺(1)~(6)。
很多依托扑克牌进行的游戏都要先洗牌。下面的Java代码运行时先生成一副扑克牌,洗牌后再按顺序打印每张牌的点数和花色。
import java.util. List;
import java.util. Arrays;
import java. util. Collections;
class Card{//扑克牌类
public static enum Face{Ace, Deuce, Three, Four, Five, Six,Seven, Eight, Nine, Ten, Jack, Queen, King};//枚举牌点
public static enum Suit{ Clubs, Diamonds, Hearts, Spades};//枚举花色
private final Face face;
private final Suit suit;
public Card( Face face, Suit suit ){
__(1)__ face = face;
__(2)__ suit= suit;
}
public Face getFace() {return face;}
public Suit getSuit() {return suit; }
public String getCard(){//返回String来表示一张牌
return string. format( "%s,%s", facer,suit );
}
}
class DeckOfCards{//牌桌类
pivate List< Card> list;//声明List以存储牌
public DeckOfCards (){//初始化牌桌并进行洗牌
Card[] deck=new Card[52];
int count=0;//牌数
//用Card对象填充牌桌
for(Card.Suit suit : Card.Suit.values()){
for(Card.Face face : Card.Face.values ()){
__(3)__=new Card(face,suit);
}
}
list=Arrays.asList( deck );
Collections. shuffle( list );
//洗牌
public void printCards (){//按4列显示52张牌
for( int i=0; i<list.size(); i++)
System. out. printf("%-19s%s",list.__(4)__,((i+1)%4==0)?"\n":"");
}
}
public class Dealer {
public static void main( String[] args){
DeckofCards player=__(5)__;
__(6)__ printcards();
}
}