public class Card { /** The card's suit: "hearts", "diamonds", "clubs", "spades". */ private String suit; /

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

public class Card { /** The card's suit: "hearts", "diamonds", "clubs", "spades". */ private String suit; /

Post by answerhappygod »

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;
}
Public Class Card The Card S Suit Hearts Diamonds Clubs Spades Private String Suit 1
Public Class Card The Card S Suit Hearts Diamonds Clubs Spades Private String Suit 1 (50.79 KiB) Viewed 25 times
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply