Game Development Reference
In-Depth Information
lq^he__h]ooOd]laI]gan
w
lq^he_bqj_pekjOd]laI]gan$%
w
y
op]pe_lq^he_bqj_pekji]gaOd]la$od]la6Opnejc%6Ikrea?hel
w
osep_d$od]la%
w
_]oaop]n6
napqnjjasOp]n$%7
^na]g7
_]oa_en_ha6
napqnjjas?en_ha$%7
^na]g7
_]oaomq]na6
napqnjjasOmq]na$%7
^na]g7
`ab]qhp6
napqnjjas?en_ha$%7
y
y
y
y
The Od]laI]gan class's only job is to create instances of the product classes. Depending on the param-
eter supplied to the i]gaOd]la method, it uses a osep_d statement to find out what kind of shape
it should make. It then uses the napqnj keyword to “return” the instance back to whatever class
requested it. The instance of the shape classes is created using the jas keyword. Here's an example:
napqnjjas?en_ha$%7
jas creates a new instance of the ?en_ha class, and napqnj sends that instance back to the class that
requested it.
For napqnj to be able to send the instance back successfully, the i]gaOd]la method needs a return
type . You looked at this before, but just as a refresher, the return type is specified by the “type” name
after the method's parameters. In this example, the return type is Ikrea?hel:
op]pe_lq^he_bqj_pekji]gaOd]la$od]la6Opnejc%6 Ikrea?hel
?en_ha, Omq]na, and Op]n all extend the Ikrea?hel class, which is why it is the return type used.
 
Search Nedrilad ::




Custom Search