For my Java class, we are learning about interfaces, polymorphism, inheritance, etc.
The homework assignment I am working on is a memory game where you have pairs of cards all face down and you turn over two at a time looking for a match. If they match, they stay visible, if they don't, the cards are turned back over and you pick two more cards.
My design so far is as follows:
public interface Hideable public abstract void hide(); public abstract void show(); public interface Speakable public abstract String speak(); public interface AnimalCard extends Hideable, Speakable public abstract boolean equals(Object obj); public class Animal implements AnimalCard public void hide() { ... } public void show() { ... } public boolean equals(Object obj) { ... } // What do I do for the speak method since a generic Animal // can't speak, but I have to provide a definition since the // Animal class is implementing the interfaces. public class Puppy extends Animal // Here is where I need to define the speak method. public String speak() { ... } My question is in the comments above. I feel like I'm implementing this incorrectly with regard to the speak() method.
abstracttoo and let the first concrete implementation deal with the implementation of the still abstract methods.