swing - Java - How to avoid overriding addObserver Observable everytime? -


i working on small game university. have model extends observable , implements interface.

due interface have override addobserver method everytime every observer add. , add additonal method interface. looks this:

@override public void addobserver(universityview universityview) {     super.addobserver(universityview);  } @override public void addobserver(courseview courseview) {     super.addobserver(courseview);  } @override public void addobserver(taskforceview taskforceview) {     super.addobserver( taskforceview); } 

in every view extended jpanel. since bound specific metrics include maximum amount of method per class, reduce one. or avoid overriding addobserver method @ all. since using parent method way.

but here problem: don't know how. there 1 solution think of use generics. not familiar generics.

thanks help!

if views extend jpanel, this

@override public void addobserver(jpanel someview) {     super.addobserver((observer) someview); } 

just idea avoiding altogether register views observers when create them. this:

public class taskforceview extends jpanel implements observer{      public taskforceview(observable observable){          ...            observable.addobserver(this);      } } 

(i didn't try out , somehow works against observer pattern, inverts way used)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -