java - Good way to implement a child class -
so have 10-15 classes (this grow larger number in time) , have similar variables within them:
temp conditions humidity load ..and stuff that. i'm looking implement parent class (abstract) better manage since runnable.
there's part call constructor each of them , it's... bad.
public threadhandler(nh.nhandler nsh, int threadnum){ this.threadnum=threadnum; this.nsh = nsh; } public threadhandler(opa.opahandler sgesh, int threadnum){ this.threadnum=threadnum; this.opash = opash; } public threadhandler(sge.sgehandler sgesh, int threadnum){ this.threadnum=threadnum; this.sgesh = sgesh; } ..... , on 15
how implement parent class do
public threadhandler(objecttype name, int threadnum){ //do stuff } thanks help.
you need create interface, say, ihandler common methods , handlers should implement interface
public interface ihandler { .... declare public methods } public nhandler implements ihandler { .... implement methods declared in ihandler.. } can have following in threadhandler public threadhandler(ihandler handler, int threadnum){ .... call methods }
Comments
Post a Comment