OK, suppose I have a square, X and X are something that has an overall relationship with other objects Drama X is a football stadium.
The X-class is full of spectators. However, the behavior of each viewer is different for a particular activity. If instead of statements, I want to put different behaviors inside the audience, so that I can use dynamic binding.
However, the problem is that what the viewer behaves affects the "soccer stadium" class. So I was thinking of passing the "this" from a football stadium class through a method, "viewer" in class so that the viewer could do something in square square stadium square?
Public Square Soccer Stadium {Speaker Interface = New Viewer (); Public Zero Vertical Behari () {s.doSomething (this); } Public Zero doSomethingthingBySpecator () {}} public square viewers apply SpecatorInterface {Public Zero doSomething (SoccerStadium s) {s.doSomethingthingBySpecator (); }} I just want to do this so that I can use dynamic binding and change behavior in Specator.doSomething () so that I can get as many as possible Different types of spectator displacement space have been passed as a feature near the Socrardium and after that there are different behaviors. Edit: What if I passed through spectator through the spectator in the speedeter's reference, instead of < Div class = "post-text" itemprop = "text">
Your implementation is absolutely fine, I've seen that kind of thing first. Yes, you can pass it through the Speed Constructor in the context of the stadium, which can be cleaner by sending it every time you need it.
However, I do not like it much; I prefer internal classes, it is not completely clear what you are trying to do, but something like this is possible:
public class external {private int some variables = 0; Public Zero Some Method () {ExtendsInner ei = New ExtendsInner (); Ei.innerMethod (); Println (someVariable); } Private Zero Another method () {someVariable ++; } Public abstract class inner {public abstract zero infarim (); } Public Sector ExtendsInner Inner {Public Zero Inner Mode (another method); SomeVariable ++; }} Public static zero main (string [] args) {external o = new external (); O.somemethod (); Unfortunately, then you have to have all your "viewer" classes inside your other class, which can actually be a long file, and thus, the ugly code. However, I think that you should definitely avoid both things because it will definitely make your code more complex.
Comments
Post a Comment