import java.util.*;
public class DisplayDeck {
public static void main(String[] args) {
Deck deck = new Deck();
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++) {
for (int rank = Card.ACE; rank <= Card.KING; rank++) {
Card card = deck.getCard(suit, rank);
System.out.format("%s of %s%n",
card.rankToString(card.getRank()),
card.suitToString(card.getSuit()));
}
}
}
}
Deck deck = new Deck();
我可以理解,它試圖將類實例甲板與對象甲板。但是,當涉及到
Card card = deck.getCard(suit, rank);
,其中卡是一類,有沒有與之相關的new
運營商,但它等同於別的東西,雖然LHS似乎更像實例化類卡。