Last active
August 29, 2015 14:20
-
-
Save ssinganamalla/c39da6b987103ff35e56 to your computer and use it in GitHub Desktop.
Single Dispatch
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
public class Program | |
{ | |
/** | |
yes thats me | |
yes thats me | |
you will have to use Double Dispatch in order for u to print 2 statements | |
**/ | |
public static void main(String[] args) | |
{ | |
Shape shape = new Shape(); | |
Surface surface = new Surface(); | |
Surface etch = new EtchASketch(); | |
shape.Draw(surface); | |
shape.Draw(etch); | |
} | |
} | |
class Surface { | |
} | |
class EtchASketch extends Surface { | |
} | |
class Shape | |
{ | |
public void Draw(Surface surface) | |
{ | |
System.out.println("yes thats me"); | |
} | |
public void Draw(EtchASketch etchASketch) | |
{ | |
System.out.println("thats you"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment