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;
/**
* Constructs a new card with the specified suit
and rank.
*/
public Card(String suit, int rank)
{
this.suit =suit;
this.rank=rank;
}
/**
* Returns this card's suit.
*/
public String suit()
{
return "";
}
/**
* Returns this card's rank.
*/
public int rank()
{
return -1;
}
/**
* Determines if this card has the same rank as
the specified card.
*/
public boolean hasSameRank(Card aCard)
{
return false;
}
/**
* Determines if this card is equal to the
specified card.
*/
public boolean isEqualTo(Card aCard)
{
return false;
}
This is the incomplete code of java, I don't want to do anything
else, just want to create the new object, and initialize the field,
but this error message always shows, 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; /
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am