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

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; /** * The car

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