libgdx - How to force subclass to implement some methods in java? -
i have screen interface in libgdx framework.
i create subclass called baselayout, initialize fields.
now every actual screen e.g. menuscreen extend baselayout class.
i want force these classes e.g. menuscreen implement 2 methods void initdata(), , void addbuttonstoscreen(). how this?
i call these methods in show method implemented in base class baselayout.
i want force these classes e.g. menuscreen implement 2 methods void initdata(), , void addbuttonstoscreen(). how this?
make baselayout abtract class , make initdata() , addbuttonstoscreen() abstract methods.
example
public abstract class baselayout extends screen { public void initdata(); public void addbuttonstoscreen(); } then make subclasses extend , implement methods..
public class concretelayout extends baselayout { public void initdata() { // code here. } public void addbuttonstoscreen() { // code here. } }
Comments
Post a Comment