Created
June 9, 2020 16:44
-
-
Save anshupitlia/4a5830cbfa3d28161e46ca8b725bf39f to your computer and use it in GitHub Desktop.
Updated Code
This file contains hidden or 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 interface Reaction { | |
void click(); | |
void hover(); | |
} | |
public class Haha implements Reaction { | |
public void onClick() { | |
System.out.println("Show Haha emoji"); | |
} | |
public void onHover() { | |
System.out.println("Haha"); | |
} | |
} | |
public class Like implements Reaction { | |
public void onClick() { | |
System.out.println("Show Like emoji"); | |
} | |
public void onHover() { | |
System.out.println("Like"); | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
Reaction reaction = new LikeButton(); | |
reaction.click(); //shows like emoji | |
reaction = new HahaButton(); | |
reaction.click(); //shows haha emoji | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment