java - How to write event class for a customized listener? -


i'm making game in java need character listen on time event handled in class.

i been using this answer make own listener it.

so fare have defined interface this:

public interface timelistener {     public void ontick(timeevent event); } 

and the timeevent this:

public class timeevent {     private int time;      public timeevent(int time) {         this.time = time;     }      public int gettime() {         return time;     } } 

in answer wrote eatevent simple wrapper class food. not quite how that. timeevent cover this?

my timeevent, unlike eatevent, needs give time along time class listeners. proper way send time along?

simply use observer design pattern it


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

how to receive file in java(servlet/jsp) -