Inappropriate Inheritance
import java.util.Random;
// Inappropriate inheritance
class Die extends Random {
// Return an integer in the range 1..6
public int roll(){
final int range = 6;
// Use the inherited nextInt method.
return 1+nextInt(range);
}
}
java.util.Stack extends java.util.Vector
Previous slide
Next slide
Back to first slide
View graphic version