Skip to content

Instantly share code, notes, and snippets.

@danishsatkut
Created August 22, 2016 08:16
Show Gist options
  • Save danishsatkut/8b46a690bfc4d8bd56642abcd945a948 to your computer and use it in GitHub Desktop.
Save danishsatkut/8b46a690bfc4d8bd56642abcd945a948 to your computer and use it in GitHub Desktop.
interface IShape {
public void draw();
}
class Rectangle implements IShape {
public void draw() {
System.out.println("RECTANGLE");
}
}
class Triangle implements IShape {
public void draw() {
System.out.println("TRIANGLE");
}
}
class Graphics {
public void render(IShape shapes[]) {
for (IShape shape : shapes) {
shape.draw(); // Polymorphic invocation to draw
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment