Skip to content

Instantly share code, notes, and snippets.

@anshupitlia
Created June 9, 2020 16:53
Show Gist options
  • Save anshupitlia/8281e2fcd1c0423961e452959b917535 to your computer and use it in GitHub Desktop.
Save anshupitlia/8281e2fcd1c0423961e452959b917535 to your computer and use it in GitHub Desktop.
Clap Button
public class ClapButton {
private int clapCount;
void onClick() {
if (clapCount < 50) {
clapCount += 1; //shorthand notation for adding 1 clap
System.out.println("You clapped!");
}
else {
System.out.println("no impact");
}
}
}
public class Main {
public static void main(String[] args) {
ClapButton clapBtn = new ClapButton();
clapBtn.onClick(); //You clapped!
clapBtn.onClick(); //You clapped!
.
.
. //50 times
clapBtn.onClick(); //no impact
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment