Skip to content

Instantly share code, notes, and snippets.

@anshupitlia
Created June 9, 2020 16:44
Show Gist options
  • Save anshupitlia/4a5830cbfa3d28161e46ca8b725bf39f to your computer and use it in GitHub Desktop.
Save anshupitlia/4a5830cbfa3d28161e46ca8b725bf39f to your computer and use it in GitHub Desktop.
Updated Code
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