Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:05:08+00:00 2026-06-15T08:05:08+00:00

I am using Java. I have got 2 classes class Card class Deck extends

  • 0

I am using Java. I have got 2 classes

class Card
class Deck extends Card

I get a constructor error.

I have to make a blackjack game for college and Deck class has to be extended.

What can I do to solve this problem?

class Card
{
    int rank, suit;
    String[] suits = { "hearts", "spades", "diamonds", "clubs" };
    String[] ranks  = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };

    Card(int suit, int rank)
    {
        this.rank=rank;
        this.suit=suit;
    }

    String toString()
    {
          return ranks[rank] + " of " + suits[suit];
    }

    int getRank() {
         return rank;
    }

    int getSuit() {
        return suit;
    }
}




class Deck extends Card{

    ArrayList <Card> cards;
    int numberdeck;
    Deck()
    {
        cards = new ArrayList<Card>();
        for (int a=0; a<=3; a++)
        {
            for (int b=0; b<=12; b++)
            {
                cards.add( new Card(a,b) );
            }
        }
    }

    Card drawFromDeck()
    {
        Random generator = new Random();
        int index= generator.nextInt( cards.size() );
        return cards.remove(index);
    }

    int getTotalCards()
    {
        return cards.size();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:05:10+00:00Added an answer on June 15, 2026 at 8:05 am

    The constructor in the subclass is supposed to invoke the corresponding constructor in the super class, but, such a constructor is not found in your code.

    Either add a constructor that takes no argument to the superclass or make the constructor in the subclass invoke the constructor in the superclass.

    You can invoke the constructor of the superclass using super(0, 0); at the beginning of the body of the constructor of the subclass.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a project that is using jni to connect java wrapper and
I have certificate created using java class CertAndKeyGen and X500Name and I am able
For an java web application, I got this error when using JRE 1.6.0_22 java.lang.SecurityException:
I'm using JCreator to work with Java. I got this exception (or maybe error?)
I am using java and have to deal with numbers larger than long (which
I am using POI 3.8 to create Excel sheets using Java I have created
I have a Java based web-application using Java Server Faces and Facelets. I am
I have to write an XML file using java.The contents should be written from
I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
I have built a web application using Java EE platform that sells one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.