Skip to content

Instantly share code, notes, and snippets.

@anshupitlia
Created June 9, 2020 16:55
Show Gist options
  • Save anshupitlia/98e2b6902063b3dbe82264e8aeb9ca61 to your computer and use it in GitHub Desktop.
Save anshupitlia/98e2b6902063b3dbe82264e8aeb9ca61 to your computer and use it in GitHub Desktop.
Medium form
public interface ClapInterface {
void onClick();
}
public class Below50 implements ClapInterface {
@Override
public void onClick() {
System.out.println("You clapped!");
}
}
public class Above50 implements ClapInterface {
@Override
public void onClick() {
System.out.println("no impact");
}
}
public class Main {
public static void main(String[] args) {
int clapCount = 0;
ClapInterface clap = new Below50();
clap.onClick(); // you clapped!
clapCount += 1;
clap.onClick(); //you clapped!
clapCount += 1;
.
.
. //50 times
clap = new Above50();
clap.onClick(); //no impact
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment