in java se 8 ,when i try to extend the player class , it shows me there is no de
ID: 3918566 • Letter: I
Question
in java se 8 ,when i try to extend the player class , it shows me there is no default constructor available in "Player" and i can not super these two objects.
public abstract class Player protected Hand hand public Player (Hand hand) this. hand- hand; /* play a card from the player's hand / returns null if they cannot play a card and the deck becomes empty do NOT return null unless you cannot play a card and the deck is empty public abstract Card play (Card top_of_discardpile, Deck deck) public final int cardsLeftO return this. hand. numberofCards 0Explanation / Answer
in java super Keyword
You are wrong in Above program
you declared
super(top_of_discard_pile,deck);
here you trying to call super class constructor()
this statement meaning is you are passing two parameter for parent class constructor (i.e player class constructor ) but you did not declared it in parent class .
first you have to declare constructor
public Player(Card c,Deck deck)
{
//intilization here
}
if you trying calling to parent class play method
super.play(top_of_discard_pile,deck);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.