Game Development Reference
In the preceding example, the ceraIkjauPk?heajp variable is declared as lq^he_ but
also op]pe_ . If you declare a variable as op]pe_ , you can access that variable from any
other class using this format:
Methods can also be declared as op]pe_ . In the previous chapter, the ^hk_g method of
the ?khheoekj class was declared as op]pe_ , so you could access the method from the
I]ej class in this way:
You would not typically define cap methods as op]pe_ , but I've done so here to make
the examples a littler clearer.
The properties are now private. But this directive is the most important change:
It's no longer directly changing one of the bank's properties. Instead, it's accessing a cap method in the
>]jg class called ceraIkjauPk?heajp. It doesn't make any presumptions about whether the response
from the bank will be pnqa or b]hoa; it simply requests this information from the bank. Whatever it
finds will be referenced in the client's [d]oIkjau property. It will be pnqa if the client has money and
b]hoa if there's no money.
This is what the new >]jg class looks like, featuring the ceraIkjauPk?heajp's cap method: