Created
August 22, 2016 08:16
-
-
Save danishsatkut/8b46a690bfc4d8bd56642abcd945a948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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