Listing 4-4
I had a couple of requests to provide more explanations regarding Listing 4-4. This was an illustration of how an instance of the class A can pass a reference to itself to an instance B. For example, There is SomeOtherClass that knows how to verify Tax and as a result can later modify some public variable(s) on the object Tax.
The object Tax passes reference to itself verifyTax(this), the instance of SomeOtherClass can do some calculations and call a method to set the results on Tax.
There is a more concrete example of passing references between the objects on page 93, where Calculator (the UI class) passes the reference to itself to CalculatorEngine - this one does the calculations and then changes the display field content on the Calculator as in Listing 9-7.
|