In java se8, how could i create a subclass of an abstract class? I did override
ID: 3918552 • Letter: I
Question
In java se8, how could i create a subclass of an abstract class? I did override a abstract constractor from that abstract class but it still shows me there is no default constructor in player, and when i try to super that two object, it shows me could not apply. And by the way what should i do to start making the model of the game since this concreat class i make is not for play only for the model of the game. Could not change any constructor and method in player class.
4: Crazy Eights Consider the provided abstract Player class. You will create a new class called CrazyEightsPlayer that is a subclass the Player class. The crazy eights player class simulates a valid player of the game crazy eights. The rules for our version of Crazy Eights is as follows: 1. The game starts with each player being given some number of cards from the deck. 2. A single card is taken from the deck and placed on top of the discard pile (and is visible to the player) 3. A player's turn consists of taking zero or more cards from the deck (adding them to their hand) and then playing a card on the top of the discard pile (removing it from their hand)Explanation / Answer
1) while creating a subclass object it automatically calls deafault constructor of the super class if you do not change this behaviour by using super keyword. there is no default constructor in Player class so it will give compile time error (no default constructor found in player) when you create crazyEightPlayer class object.
2)In create crazyEightPlayer class you used super keyword in wrong manner.
you should do super.play(top_of_discard_pile,play) if you want to call super class method.
but your super(...) will generate compile time error.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.