Extending class, implicit super constructor is undefined error
in
Programming Questions
•
10 months ago
hi,
I have got 2 classes
class Card
class Deck extends Card
I get constructor error.
I have to make a blackjack game for college and Deck class has to be extended.
What else can i do to solve this problem?
thanks
I have got 2 classes
class Card
class Deck extends Card
I get constructor error.
I have to make a blackjack game for college and Deck class has to be extended.
What else can i do to solve this problem?
thanks
- 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