Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Toaster {
- public void toast(String text);
- }
- class DesktopToaster implements Toaster {
- public void toast(String text) {
- ...
- }
- }
- class AndroidToaster implements Toaster {
- public void toast(String text) {
- ....
- }
- }
- class MyApplicationListener implements ApplicationListener {
- Toaster toaster;
- public MyApplicationListener(Toaster toaster) {
- this.toaster = toaster;
- }
- public void render() {
- if(shit)
- toaster.toast("Shit!");
- }
- }
- class DesktopStarter {
- public static void main(String[] argv) {
- new JoglApplication(new MyApplicationListener(new DesktopToaster()), ...);
- }
- }
- class AndroidStarter extends AndroidApplication {
- public onCreate(Bundle ...) {
- initialize(new MyApplicationListener(new AndroidToaster(), ...);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement