代码搜索:Polymorphism
找到约 740 项符合「Polymorphism」的源代码
代码结果 740
www.eeworm.com/read/373369/9460322
java randomshapegenerator.java
//: polymorphism/shape/RandomShapeGenerator.java
// A "factory" that randomly creates shapes.
package polymorphism.shape;
import java.util.*;
public class RandomShapeGenerator {
private Rando
www.eeworm.com/read/373369/9460324
java polyconstructors.java
//: polymorphism/PolyConstructors.java
// Constructors and polymorphism
// don't produce what you might expect.
import static net.mindview.util.Print.*;
class Glyph {
void draw() { print("Gly
www.eeworm.com/read/373369/9460331
java wind.java
//: polymorphism/music/Wind.java
package polymorphism.music;
// Wind objects are instruments
// because they have the same interface:
public class Wind extends Instrument {
// Redefine interf
www.eeworm.com/read/373369/9460332
java instrument.java
//: polymorphism/music/Instrument.java
package polymorphism.music;
import static net.mindview.util.Print.*;
class Instrument {
public void play(Note n) {
print("Instrument.play()");
}
www.eeworm.com/read/373369/9460347
java privateoverride.java
//: polymorphism/PrivateOverride.java
// Trying to override a private method.
package polymorphism;
import static net.mindview.util.Print.*;
public class PrivateOverride {
private void f() {
www.eeworm.com/read/169058/9883009
java rtti.java
//: polymorphism/RTTI.java
// Downcasting & Runtime type information (RTTI).
// {ThrowsException}
class Useful {
public void f() {}
public void g() {}
}
class MoreUseful extends Useful
www.eeworm.com/read/169058/9883013
java square.java
//: polymorphism/shape/Square.java
package polymorphism.shape;
import static net.mindview.util.Print.*;
public class Square extends Shape {
public void draw() { print("Square.draw()"); }
pu
www.eeworm.com/read/169058/9883014
java circle.java
//: polymorphism/shape/Circle.java
package polymorphism.shape;
import static net.mindview.util.Print.*;
public class Circle extends Shape {
public void draw() { print("Circle.draw()"); }
pu