user interface - Java Implementable Class Creation? -


so want make game engine, , instantly realized stuff has "auto-imported". example, when implements runnable, error because has have run() method in class.

how do this? how have class, when implemented, force method, , automatically run method?

an example, usable when answering:

i have frame class. frame class will, when implemented, use method, in class implemented it, named draw(), , have implemented use frame class. example code:

public class test implements hframe {     // constructor     public test() {      }      // method called when test run     public static void init() {         hframe f = new hframe(width, height);         f.display(); // makes frame visible     }      // method frame call when implemented     public void draw() {         // stuff draw         new circle(0, 0, 50, 50);     } } 

using comments, how work?

thanks help, , apologize if isnt worded best...

in order "force" class implement methods use interface, example of below

public interface gameengineinterface {     void init();     void draw();     vector3d annothermethod(object object); } 

any class going used game engine implement gameengineinterface engine.

gameengine methods work such

public object somemethod(gameengineinterface anyobjectthatimplementsgameengineinterface){     //method body } 

the gameengine doesn't care specifics of implimenting methods, can call methods.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -