Created
June 9, 2020 16:55
-
-
Save anshupitlia/98e2b6902063b3dbe82264e8aeb9ca61 to your computer and use it in GitHub Desktop.
Medium form
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 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