public class Card
{
/** The card's suit: "hearts", "diamonds", "clubs", "spades".
*/
private String suit;
/**
* The card's rank, between 1 and 13 (1 represents the ace, 11
represents
* the jack, 12 represents the queen, and 13 represents the
king.)
*/
private int rank;
This is the incomplete code of java, but the error message shows
when I try to create the new object, initialize the field, why?
BlueJ: cards Project Edit Tools View Help New Class... Deck Compile «unit test>> Deck Test «unit test>> Card Test Hand «unit test>> Hand Test Card Bluel: Create Object Constructs a new card with the specified suit and rank. Card(String suit, int rank) Name of Instance: card1 new Card( "hearts", "diamonds", "clubs", "spades" 13 Error: <identifier> expected OK □ X 4 4 Cancel 1 X Q
public class Card { /** The card's suit: "hearts", "diamonds", "clubs", "spades". */ private String suit; /** * The car
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am