Output
5
4
3
2
1
FirstClass class, someAction method
SecondClass class, someAction method
Specific action for anonymous SecondClass, param = 0
The number of created Action objects is 2
SecondClass class, someAction method
Specific action for anonymous SecondClass, param = -1
The number of created Action objects is 3
It really was. I suggest debugging to follow along. Essentially the code makes the Solution's "someAction" go throw an if logic based on "param" number. The if logic either return a firstClass's
"someAction" or return a Solution's "smartAction". since the parm starts with a 5, the if logic keeps returning the solutions calss"smartAction" which basically re-excute the same if logic ...so kinda like a loop where the firstclass method keeps calling back it's super calss's method "Solution" someActione until the "param" is less than 0...This loop I am talking about all happens in the "getDependantAction method which returns an Action Object. The action object either is the Solution's calss or the first class. .but really watching the debug go through it might help more espically around the "This" keyword which is kinda confusing with outer and inner classes
My impression is that a lot of these tasks are deliberately confusing. On the first one, e.g., if we follow exactly the steps that Kim gave us on the last lesson, the code won't work (it won't even compile). So we'll have to search for the solution somewhere else, which makes the task not "easy" at all. There's a lack of explanation and exemples.
Fortunately we have some people on the help session that already passed such tasks, so we can copy and paste their codes, hoping that one day we will find explanations and will understand the solutions.
GO TO FULL VERSION