Skip to content

Instantly share code, notes, and snippets.

@sembozdemir
Created April 27, 2016 15:06
Show Gist options
  • Save sembozdemir/af644dfc6adc227cb913f13941951616 to your computer and use it in GitHub Desktop.
Save sembozdemir/af644dfc6adc227cb913f13941951616 to your computer and use it in GitHub Desktop.
ListenerExample/Main.java
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
RandomGenerator randomGenerator = new RandomGenerator();
randomGenerator.setListener(new OnNumberGeneratedListener() {
@Override
public void onNumberGenerated(int number) {
System.out.println(number);
}
});
while(true) {
scanner.nextLine();
randomGenerator.requestNumber();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment