First of all, some general thoughts... Bounceable should NOT extends Ball because a Bounceable Object IS NOT in all cases a Ball (IS A is what extends actually mean)...
I would suggest the following:
1. create a Bounceable interface
Code:
public interface Bounceable {
String bounce(); // all method declarations in interfaces are public abstract implicitly
}
2. create an abstract Ball class
Code:
public abstract class Ball {
private String type;
protected Ball(String type) {
this.type = type;
}
public getType() {
return type;
}
public abstract void play();
}
3. let Basketball implement Bounceable and extend Ball (so a Basketball IS A ball, which is right AND a bounceable object, which is also true)
Code:
public class Basketball extends Ball implements Bounceable {
public Basketball(String type) {
super(type);
}
@Override
public String bounce() {
return " dribble... ";
}
@Override
public void play() {
System.out.println("Basketball begins with a tipoff");
}
}
That should do the trick ;-)! Didn't try out the code but at least it should give you an idea :-)!