home *** CD-ROM | disk | FTP | other *** search
Unknown | 1993-06-20 | 10.4 KB |
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was not able to be converted.
This format is not currently supported by dexvert.
Confidence | Program | Detection | Match Type | Support
|
---|
66%
| dexvert
| Wanton Packer Module (music/wantonPacker)
| ext
| Supported |
100%
| file
| data
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 00 00 00 00 00 00 00 | 04 00 29 4e 04 00 24 3b |........|..)N..$;|
|00000010| 04 00 06 95 04 00 06 9d | 04 00 02 0c 00 1e 2e 3c |........|.......<|
|00000020| 00 05 48 e0 00 1e 2b 64 | 00 05 48 98 00 1e 2d 8c |..H...+d|..H...-.|
|00000030| 00 00 00 00 00 00 00 00 | 00 04 00 00 00 00 00 00 |........|........|
|00000040| 09 00 00 00 00 00 00 ff | 00 00 00 00 00 00 df 66 |........|.......f|
|00000050| 00 00 e1 ae 02 64 00 00 | 20 9a 00 2c 00 00 00 00 |.....d..| ..,....|
|00000060| 00 00 00 00 00 3a 00 00 | 00 00 ff 00 00 00 00 00 |.....:..|........|
|00000070| 00 00 00 00 00 00 01 01 | 02 64 00 00 00 48 00 48 |........|.d...H.H|
|00000080| 00 01 00 18 03 18 02 64 | 00 00 00 00 02 da 02 2f |.......d|......./|
|00000090| 00 64 00 04 19 00 04 00 | 24 55 00 0a df b8 00 5a |.d......|$U.....Z|
|000000a0| 00 2a 04 00 24 55 00 0a | df b8 00 5a 00 2a fc 71 |.*..$U..|...Z.*.q|
|000000b0| 00 00 06 45 00 00 00 00 | ff 00 00 00 00 00 00 00 |...E....|........|
|000000c0| 29 a4 00 00 29 a4 00 00 | 29 a4 00 00 3e 8d 00 00 |)...)...|)...>...|
|000000d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000100| 00 00 00 00 04 00 23 e5 | 04 00 24 3b 04 00 06 95 |......#.|..$;....|
|00000110| 04 00 06 9d 04 00 02 0c | 00 1e 20 48 00 1e 21 b8 |........|.. H..!.|
|00000120| 00 05 49 5c 00 1e 20 64 | 00 1e 21 94 00 00 00 00 |..I\.. d|..!.....|
|00000130| 00 00 00 00 00 04 00 00 | 00 00 00 00 09 00 00 00 |........|........|
|00000140| 00 00 00 ff 00 00 00 00 | 00 00 df 66 00 00 e1 ad |........|...f....|
|00000150| 02 64 00 00 20 9a 00 2c | 00 00 00 00 00 00 00 00 |.d.. ..,|........|
|00000160| 00 3a 00 00 00 00 ff 00 | 00 00 00 00 00 00 00 00 |.:......|........|
|00000170| 00 00 01 01 02 64 00 00 | 00 48 00 48 00 01 00 18 |.....d..|.H.H....|
|00000180| 03 18 02 64 00 00 00 00 | 02 da 02 2f 00 64 00 04 |...d....|.../.d..|
|00000190| 19 00 04 00 06 bd 00 0a | df b8 00 5a 00 2a 04 00 |........|...Z.*..|
|000001a0| 06 bd 00 0a df b8 00 5a | 00 2a fc 71 00 00 00 f5 |.......Z|.*.q....|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 24 55 00 00 |........|....$U..|
|000001c0| 24 55 00 00 24 55 00 00 | 3e 8d 00 00 00 00 00 00 |$U..$U..|>.......|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 00 04 0d 0d 0d 0d 00 04 | 0d 0d 0d 0d 00 78 00 03 |........|.....x..|
|00000210| 00 00 00 48 00 48 00 00 | 00 00 02 da 02 2f 00 00 |...H.H..|...../..|
|00000220| 00 00 03 18 02 64 01 5b | 05 28 03 fc 00 02 00 00 |.....d.[|.(......|
|00000230| 00 48 00 48 00 00 00 00 | 03 18 02 64 00 01 00 00 |.H.H....|...d....|
|00000240| 00 64 00 00 00 01 00 01 | 01 01 00 00 00 01 27 0f |.d......|......'.|
|00000250| 00 01 00 01 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000260| 00 02 00 19 01 90 00 00 | 00 00 00 40 00 00 00 00 |........|...@....|
|00000270| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000280| 00 00 00 00 00 00 00 60 | 0d 4f 62 6a 65 63 74 20 |.......`|.Object |
|00000290| 42 61 73 65 64 20 43 6f | 6d 70 75 74 69 6e 67 3a |Based Co|mputing:|
|000002a0| 20 41 20 4e 65 78 74 53 | 74 65 70 20 54 75 74 6f | A NextS|tep Tuto|
|000002b0| 72 69 61 6c 20 61 6e 64 | 20 43 6f 6f 6b 62 6f 6f |rial and| Cookboo|
|000002c0| 6b 20 2d 20 44 47 4d 0d | 43 68 61 70 74 65 72 20 |k - DGM.|Chapter |
|000002d0| 37 3a 49 6e 69 74 69 61 | 6c 69 7a 69 6e 67 20 4f |7:Initia|lizing O|
|000002e0| 62 6a 65 63 74 73 0d 0d | 00 21 0d 50 61 67 65 20 |bjects..|.!.Page |
|000002f0| 37 2d fd 00 f7 20 20 20 | 20 20 20 20 fd 01 f7 20 |7-... | ... |
|00000300| 20 20 20 20 20 20 fd 02 | f7 0d 0d 00 64 ff 00 15 | ..|....d...|
|00000310| 09 00 f7 f9 03 f7 fd 03 | f7 f9 00 f7 ff 00 15 0a |........|........|
|00000320| 00 f7 53 65 65 20 4a 6f | 75 72 6e 61 6c 20 6f 66 |..See Jo|urnal of|
|00000330| 20 4f 62 6a 65 63 74 20 | 4f 72 69 65 6e 74 65 64 | Object |Oriented|
|00000340| 20 50 72 6f 67 72 61 6d | 6d 69 6e 67 2c 20 20 53 | Program|ming, S|
|00000350| 75 6d 6d 65 72 20 31 39 | 39 30 2c 20 4a 6f 68 6e |ummer 19|90, John|
|00000360| 20 48 6f 70 6b 69 6e 73 | 20 61 72 74 69 63 6c 65 | Hopkins| article|
|00000370| 0d 01 a1 0d 55 70 20 75 | 6e 74 69 6c 20 6e 6f 77 |....Up u|ntil now|
|00000380| 2c 20 61 6c 6c 20 6f 66 | 20 6f 75 72 20 6d 65 74 |, all of| our met|
|00000390| 68 6f 64 73 20 61 6c 77 | 61 79 73 20 73 74 61 72 |hods alw|ays star|
|000003a0| 74 65 64 20 77 69 74 68 | 20 61 20 64 61 73 68 20 |ted with| a dash |
|000003b0| 28 22 2d 22 29 20 63 68 | 61 72 61 63 74 65 72 20 |("-") ch|aracter |
|000003c0| 6f 72 20 61 6e 20 6d 69 | 6e 75 73 20 73 69 67 6e |or an mi|nus sign|
|000003d0| 2e 20 20 54 68 69 73 20 | 69 6e 64 69 63 61 74 65 |. This |indicate|
|000003e0| 64 20 74 68 61 74 20 65 | 61 63 68 20 6f 66 20 74 |d that e|ach of t|
|000003f0| 68 65 20 6d 65 73 73 61 | 67 65 73 20 77 65 6e 74 |he messa|ges went|
|00000400| 20 74 6f 20 69 6e 73 74 | 61 6e 63 65 73 20 6f 66 | to inst|ances of|
|00000410| 20 6f 62 6a 65 63 74 73 | 2e 20 20 49 66 20 77 65 | objects|. If we|
|00000420| 20 73 74 61 72 74 20 61 | 20 6d 65 74 68 6f 64 20 | start a| method |
|00000430| 77 69 74 68 20 61 20 22 | 2b 22 20 73 69 67 6e 2c |with a "|+" sign,|
|00000440| 20 74 68 65 20 6d 65 73 | 73 61 67 65 20 77 69 6c | the mes|sage wil|
|00000450| 6c 20 6e 6f 74 20 67 6f | 20 74 6f 20 69 6e 73 74 |l not go| to inst|
|00000460| 61 6e 63 65 73 20 6f 66 | 20 74 68 65 20 6f 62 6a |ances of| the obj|
|00000470| 65 63 74 2c 20 62 75 74 | 20 77 69 6c 6c 20 62 65 |ect, but| will be|
|00000480| 20 72 65 64 69 72 65 63 | 74 65 64 20 74 6f 20 67 | redirec|ted to g|
|00000490| 6f 20 74 6f 20 74 68 65 | 20 66 61 63 74 6f 72 79 |o to the| factory|
|000004a0| 20 74 68 61 74 20 63 72 | 65 61 74 65 64 20 74 68 | that cr|eated th|
|000004b0| 65 20 6f 62 6a 65 63 74 | 2e 20 20 4c 65 74 73 20 |e object|. Lets |
|000004c0| 74 61 6b 65 20 61 20 6c | 6f 6f 6b 20 61 74 20 74 |take a l|ook at t|
|000004d0| 68 65 20 63 6f 64 65 20 | 77 65 20 77 6f 75 6c 64 |he code |we would|
|000004e0| 20 69 6e 73 65 72 74 20 | 69 6e 74 6f 20 65 78 65 | insert |into exe|
|000004f0| 72 63 69 73 65 20 33 2d | 34 20 74 6f 20 69 6e 69 |rcise 3-|4 to ini|
|00000500| 74 69 61 6c 69 7a 65 20 | 74 68 65 20 6f 62 6a 65 |tialize |the obje|
|00000510| 63 74 3a 0d 01 65 0d 48 | 65 72 65 20 69 73 20 74 |ct:..e.H|ere is t|
|00000520| 68 65 20 63 6f 6d 70 6c | 65 74 65 20 70 72 6f 67 |he compl|ete prog|
|00000530| 72 61 6d 20 66 6f 72 20 | 63 72 65 61 74 69 6e 67 |ram for |creating|
|00000540| 20 61 6e 20 6f 62 6a 65 | 63 74 20 74 68 61 74 20 | an obje|ct that |
|00000550| 69 73 20 68 61 73 20 61 | 6e 20 69 6e 74 65 67 65 |is has a|n intege|
|00000560| 72 20 61 73 20 61 6e 20 | 69 6e 73 74 61 6e 63 65 |r as an |instance|
|00000570| 20 76 61 72 69 61 62 6c | 65 2c 20 69 6e 69 74 69 | variabl|e, initi|
|00000580| 61 6c 69 7a 65 73 20 74 | 68 61 74 20 6e 75 6d 62 |alizes t|hat numb|
|00000590| 65 72 20 74 6f 20 31 30 | 30 20 69 6e 20 74 68 65 |er to 10|0 in the|
|000005a0| 20 66 61 63 74 6f 72 79 | 20 61 6e 64 20 68 61 73 | factory| and has|
|000005b0| 20 74 77 6f 20 61 63 74 | 69 6f 6e 20 6d 65 74 68 | two act|ion meth|
|000005c0| 6f 64 73 20 74 68 61 74 | 20 69 6e 63 72 65 6d 65 |ods that| increme|
|000005d0| 6e 74 20 61 6e 64 20 64 | 65 63 72 65 6d 65 6e 74 |nt and d|ecrement|
|000005e0| 20 74 68 65 20 73 74 61 | 74 65 20 6f 66 20 74 68 | the sta|te of th|
|000005f0| 65 20 69 6e 73 74 61 6e | 63 65 20 76 61 72 69 61 |e instan|ce varia|
|00000600| 62 6c 65 2e 20 20 54 68 | 65 20 6c 69 6e 65 73 20 |ble. Th|e lines |
|00000610| 77 65 20 61 64 64 20 61 | 72 65 20 69 6e 20 62 6f |we add a|re in bo|
|00000620| 6c 64 2e 20 20 54 68 65 | 20 72 65 73 74 20 6f 66 |ld. The| rest of|
|00000630| 20 74 68 65 20 6c 69 6e | 65 73 20 61 72 65 20 63 | the lin|es are c|
|00000640| 72 65 61 74 65 64 20 62 | 79 20 74 68 65 20 22 75 |reated b|y the "u|
|00000650| 6e 70 61 72 73 65 22 20 | 6f 70 65 72 61 74 69 6f |nparse" |operatio|
|00000660| 6e 20 66 6f 72 6d 20 49 | 6e 74 65 72 66 61 63 65 |n form I|nterface|
|00000670| 20 42 75 69 6c 64 65 72 | 2e 0d 0d 00 18 04 00 02 | Builder|........|
|00000680| 00 00 38 04 00 02 06 00 | 38 04 00 02 86 00 38 04 |..8.....|8.....8.|
|00000690| 00 02 e8 00 2a 00 06 24 | 00 03 0b 00 0f 00 1e 00 |....*..$|........|
|000006a0| 20 00 00 00 01 00 63 61 | 66 00 00 79 72 00 6b 61 | .....ca|f..yr.ka|
|000006b0| 66 73 65 69 72 00 00 61 | 32 00 00 f5 6c 04 f8 f5 |fseir..a|2...l...|
|000006c0| f6 ff 00 15 24 01 f7 43 | 68 61 70 74 65 72 20 37 |....$..C|hapter 7|
|000006d0| 3a 20 49 6e 69 74 69 61 | 6c 69 7a 69 6e 67 20 4f |: Initia|lizing O|
|000006e0| 62 6a 65 63 74 73 3a 20 | 41 20 54 6f 75 72 20 6f |bjects: |A Tour o|
|000006f0| 66 20 74 68 65 20 46 61 | 63 74 6f 72 79 ff 00 15 |f the Fa|ctory...|
|00000700| 0c 00 f7 0d 0d 0d 0d 0d | 0d 0d 0d 0d 0d ff 00 15 |........|........|
|00000710| 0c 02 f7 0d 0d ff 00 15 | 24 01 f7 0d ff 00 15 0a |........|$.......|
|00000720| 00 f7 66 61 63 b7 74 6f | b7 72 79 20 5c 27 66 61 |..fac.to|.ry \'fa|
|00000730| 6b 2d 74 28 65 2d 29 72 | 65 c5 5c 20 6e 2c 20 20 |k-t(e-)r|e.\ n, |
|00000740| 70 6c 20 2d 72 69 65 73 | 0d 28 31 35 38 32 29 0d |pl -ries|.(1582).|
|00000750| 31 3a 20 61 20 73 74 61 | 74 69 6f 6e 20 77 68 65 |1: a sta|tion whe|
|00000760| 72 65 20 72 65 73 69 64 | 65 6e 74 20 66 61 63 74 |re resid|ent fact|
|00000770| 6f 72 73 20 74 72 61 64 | 65 0d 32 61 3a 20 61 20 |ors trad|e.2a: a |
|00000780| 62 75 69 6c 64 69 6e 67 | 20 6f 72 20 73 65 74 20 |building| or set |
|00000790| 6f 66 20 62 75 69 6c 64 | 69 6e 67 73 20 77 69 74 |of build|ings wit|
|000007a0| 68 20 66 61 63 69 6c 69 | 74 69 65 73 20 66 6f 72 |h facili|ties for|
|000007b0| 20 6d 61 6e 75 66 61 63 | 74 75 72 69 6e 67 0d 62 | manufac|turing.b|
|000007c0| 3a 20 74 68 65 20 73 65 | 61 74 20 6f 66 20 73 6f |: the se|at of so|
|000007d0| 6d 65 20 6b 69 6e 64 20 | 6f 66 20 70 72 6f 64 75 |me kind |of produ|
|000007e0| 63 74 69 6f 6e 20 28 74 | 68 65 20 76 69 63 65 20 |ction (t|he vice |
|000007f0| 66 61 63 74 6f 72 69 65 | 73 20 6f 66 20 74 68 65 |factorie|s of the|
|00000800| 20 73 6c 75 6d 73 29 0d | d0 20 66 61 63 b7 74 6f | slums).|. fac.to|
|00000810| b7 72 79 b7 6c 69 6b 65 | 20 5c 2d 2c 6c f0 05 c5 |.ry.like| \-,l...|
|00000820| 6b 5c 20 61 64 6a 20 0d | 0d 0d f9 00 f7 57 65 20 |k\ adj .|.....We |
|00000830| 68 61 76 65 20 6e 6f 77 | 20 69 6e 74 72 6f 64 75 |have now| introdu|
|00000840| 63 65 64 20 74 68 65 20 | 66 6f 75 72 20 66 75 6e |ced the |four fun|
|00000850| 64 61 6d 65 6e 74 61 6c | 20 74 65 63 68 6e 69 71 |damental| techniq|
|00000860| 75 65 73 20 75 73 65 64 | 20 62 79 20 6f 62 6a 65 |ues used| by obje|
|00000870| 63 74 20 62 61 73 65 64 | 20 63 6f 6d 70 75 74 69 |ct based| computi|
|00000880| 6e 67 20 73 79 73 74 65 | 6d 73 20 74 6f 20 61 6c |ng syste|ms to al|
|00000890| 6c 6f 77 20 79 6f 75 20 | 74 6f 20 62 65 20 70 72 |low you |to be pr|
|000008a0| 6f 64 75 63 74 69 76 65 | 2e 20 20 57 65 20 77 69 |oductive|. We wi|
|000008b0| 6c 6c 20 6e 6f 77 20 74 | 61 6b 65 20 61 20 62 69 |ll now t|ake a bi|
|000008c0| 74 20 6d 6f 72 65 20 64 | 65 74 61 69 6c 65 64 20 |t more d|etailed |
|000008d0| 6c 6f 6f 6b 20 61 74 20 | 68 6f 77 20 74 6f 20 67 |look at |how to g|
|000008e0| 65 74 20 67 6f 69 6e 67 | 20 63 72 65 61 74 69 6e |et going| creatin|
|000008f0| 67 20 6f 62 6a 65 63 74 | 73 2e 20 20 4f 6e 65 20 |g object|s. One |
|00000900| 6f 66 20 74 68 65 20 66 | 69 72 73 74 20 74 68 69 |of the f|irst thi|
|00000910| 6e 67 73 20 77 65 20 6f | 66 74 65 6e 20 6e 65 65 |ngs we o|ften nee|
|00000920| 64 20 74 6f 20 64 6f 20 | 77 68 65 6e 20 63 72 65 |d to do |when cre|
|00000930| 61 74 69 6e 67 20 61 20 | 6e 65 77 20 6f 62 6a 65 |ating a |new obje|
|00000940| 63 74 20 69 73 20 73 65 | 74 20 61 6e 20 69 6e 69 |ct is se|t an ini|
|00000950| 74 69 61 6c 20 76 61 6c | 75 65 20 61 73 73 6f 63 |tial val|ue assoc|
|00000960| 69 61 74 65 64 20 77 69 | 74 68 20 61 6e 20 6f 62 |iated wi|th an ob|
|00000970| 6a 65 63 74 2e 20 20 54 | 68 65 20 76 61 6c 75 65 |ject. T|he value|
|00000980| 73 20 69 6e 73 69 64 65 | 20 61 6e 20 6f 62 6a 65 |s inside| an obje|
|00000990| 63 74 20 61 72 65 20 73 | 74 6f 72 65 64 20 69 6e |ct are s|tored in|
|000009a0| 20 69 6e 73 74 61 6e 63 | 65 20 76 61 72 69 61 62 | instanc|e variab|
|000009b0| 6c 65 73 2e 20 20 54 68 | 65 79 20 61 72 65 20 74 |les. Th|ey are t|
|000009c0| 68 65 20 69 6e 74 65 67 | 65 72 73 2c 20 66 6c 6f |he integ|ers, flo|
|000009d0| 61 74 69 6e 67 20 70 6f | 69 6e 74 20 6e 75 6d 62 |ating po|int numb|
|000009e0| 65 72 73 2c 20 73 74 72 | 69 6e 67 73 20 61 6e 64 |ers, str|ings and|
|000009f0| 20 6f 74 68 65 72 20 64 | 61 74 61 20 73 74 72 75 | other d|ata stru|
|00000a00| 63 74 75 72 65 73 20 69 | 6e 73 69 64 65 20 6f 75 |ctures i|nside ou|
|00000a10| 72 20 62 6c 61 63 6b 20 | 62 6f 78 65 73 2e 20 20 |r black |boxes. |
|00000a20| 49 6e 20 43 68 61 70 74 | 65 72 20 33 20 77 65 20 |In Chapt|er 3 we |
|00000a30| 63 72 65 61 74 65 64 20 | 61 6e 20 6f 62 6a 65 63 |created |an objec|
|00000a40| 74 20 74 68 61 74 20 70 | 72 69 6e 74 65 64 20 6f |t that p|rinted o|
|00000a50| 75 74 20 74 68 65 20 77 | 6f 72 64 73 20 22 68 65 |ut the w|ords "he|
|00000a60| 6c 6c 6f 20 77 6f 72 6c | 64 22 20 77 68 65 6e 20 |llo worl|d" when |
|00000a70| 61 20 62 75 74 74 6f 6e | 20 77 61 73 20 70 72 65 |a button| was pre|
|00000a80| 73 73 65 64 2e 20 20 45 | 78 65 72 63 69 73 65 20 |ssed. E|xercise |
|00000a90| 66 6f 75 72 20 73 75 67 | 67 65 73 74 65 64 20 63 |four sug|gested c|
|00000aa0| 72 65 61 74 69 6e 67 20 | 61 6e 20 6f 62 6a 65 63 |reating |an objec|
|00000ab0| 74 20 74 68 61 74 20 77 | 6f 75 6c 64 20 68 61 76 |t that w|ould hav|
|00000ac0| 65 20 74 77 6f 20 61 63 | 74 69 6f 6e 20 6d 65 74 |e two ac|tion met|
|00000ad0| 68 6f 64 73 2e 20 20 4f | 6e 65 20 77 6f 75 6c 64 |hods. O|ne would|
|00000ae0| 20 69 6e 63 72 65 6d 65 | 6e 74 20 74 68 65 20 69 | increme|nt the i|
|00000af0| 6e 74 65 72 6e 61 6c 20 | 73 74 61 74 65 20 6f 66 |nternal |state of|
|00000b00| 20 61 6e 20 6f 62 6a 65 | 63 74 20 61 6e 64 20 6f | an obje|ct and o|
|00000b10| 6e 65 20 77 6f 75 6c 64 | 20 64 65 63 72 65 6d 65 |ne would| decreme|
|00000b20| 6e 74 20 74 68 65 20 73 | 74 61 74 65 20 6f 66 20 |nt the s|tate of |
|00000b30| 61 6e 20 6f 62 6a 65 63 | 74 2e 20 20 42 75 74 20 |an objec|t. But |
|00000b40| 77 68 61 74 20 69 66 20 | 77 65 20 77 61 6e 74 65 |what if |we wante|
|00000b50| 64 20 74 6f 20 73 74 61 | 72 74 20 74 68 65 20 69 |d to sta|rt the i|
|00000b60| 6e 69 74 69 61 6c 20 73 | 74 61 74 65 20 6f 66 20 |nitial s|tate of |
|00000b70| 74 68 65 20 6f 62 6a 65 | 63 74 20 61 74 20 61 20 |the obje|ct at a |
|00000b80| 76 61 6c 75 65 20 6f 74 | 68 65 72 20 74 68 65 6e |value ot|her then|
|00000b90| 20 7a 65 72 6f 3f 20 20 | 49 66 20 77 65 20 70 75 | zero? |If we pu|
|00000ba0| 74 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |t the fo|llowing |
|00000bb0| 6c 69 6e 65 73 3a 0d 03 | 9e ff 00 15 0c 00 f7 0d |lines:..|........|
|00000bc0| fc 00 6c 02 0a 00 6c 00 | 0e 02 40 06 30 f7 ff 00 |..l...l.|..@.0...|
|00000bd0| 16 0a 00 f7 2f 2f 20 49 | 6e 69 74 69 61 6c 69 7a |....// I|nitializ|
|00000be0| 65 20 74 68 65 20 73 74 | 61 74 65 20 6f 66 20 69 |e the st|ate of i|
|00000bf0| 6e 73 74 61 6e 63 65 20 | 76 61 6c 75 65 0d 6d 79 |nstance |value.my|
|00000c00| 49 6e 74 20 3d 20 31 30 | 30 3b ff 00 15 0a 00 f7 |Int = 10|0;......|
|00000c10| 0d fc 00 5a 02 0a 00 5a | 00 0e 01 b0 06 30 f7 0d |...Z...Z|.....0..|
|00000c20| 69 6e 20 65 69 74 68 65 | 72 20 74 68 65 20 61 63 |in eithe|r the ac|
|00000c30| 74 69 6f 6e 20 6d 65 74 | 68 6f 64 73 20 69 74 20 |tion met|hods it |
|00000c40| 77 6f 75 6c 64 20 67 65 | 74 20 72 65 2d 69 6e 69 |would ge|t re-ini|
|00000c50| 74 69 61 6c 69 7a 65 64 | 20 65 76 65 72 79 20 74 |tialized| every t|
|00000c60| 69 6d 65 20 77 65 20 70 | 72 65 73 73 20 74 68 65 |ime we p|ress the|
|00000c70| 20 62 75 74 74 6f 6e 2e | 20 20 57 65 20 63 6f 75 | button.| We cou|
|00000c80| 6c 64 20 61 64 64 20 61 | 6e 6f 74 68 65 72 20 62 |ld add a|nother b|
|00000c90| 75 74 74 6f 6e 20 63 61 | 6c 6c 65 64 20 22 69 6e |utton ca|lled "in|
|00000ca0| 69 74 69 61 6c 69 7a 65 | 22 20 61 6e 64 20 68 61 |itialize|" and ha|
|00000cb0| 76 65 20 61 6e 6f 74 68 | 65 72 20 61 63 74 69 6f |ve anoth|er actio|
|00000cc0| 6e 20 6d 65 74 68 6f 64 | 20 72 75 6e 20 74 68 69 |n method| run thi|
|00000cd0| 73 20 63 6f 64 65 20 65 | 76 65 72 79 20 74 69 6d |s code e|very tim|
|00000ce0| 65 20 77 65 20 72 61 6e | 20 74 68 65 20 70 72 6f |e we ran| the pro|
|00000cf0| 67 72 61 6d 2c 20 62 75 | 74 20 74 68 61 74 20 77 |gram, bu|t that w|
|00000d00| 6f 75 6c 64 20 72 65 71 | 75 69 72 65 20 75 73 20 |ould req|uire us |
|00000d10| 74 6f 20 6d 61 6e 75 61 | 6c 6c 79 20 72 65 73 65 |to manua|lly rese|
|00000d20| 74 20 65 76 65 72 79 74 | 68 69 6e 67 20 65 76 65 |t everyt|hing eve|
|00000d30| 72 79 20 74 69 6d 65 20 | 74 68 65 20 70 72 6f 67 |ry time |the prog|
|00000d40| 72 61 6d 20 73 74 61 72 | 74 65 64 20 75 70 2e 20 |ram star|ted up. |
|00000d50| 20 54 68 65 72 65 20 69 | 73 20 61 20 62 65 74 74 | There i|s a bett|
|00000d60| 65 72 20 77 61 79 2e 20 | 20 57 65 20 74 61 6c 6b |er way. | We talk|
|00000d70| 65 64 20 69 6e 20 65 61 | 72 6c 69 65 72 20 63 68 |ed in ea|rlier ch|
|00000d80| 61 70 74 65 72 73 20 61 | 62 6f 75 74 20 68 6f 77 |apters a|bout how|
|00000d90| 20 61 6c 6c 20 6f 62 6a | 65 63 74 73 20 61 72 65 | all obj|ects are|
|00000da0| 20 22 63 72 65 61 74 65 | 64 22 20 66 6f 72 6d 20 | "create|d" form |
|00000db0| 69 6e 20 61 20 66 61 63 | 74 6f 72 79 2e 20 20 54 |in a fac|tory. T|
|00000dc0| 68 61 74 20 74 68 65 73 | 65 20 66 61 63 74 6f 72 |hat thes|e factor|
|00000dd0| 69 65 73 20 77 65 72 65 | 20 67 72 6f 75 70 65 64 |ies were| grouped|
|00000de0| 20 74 6f 67 65 74 68 65 | 72 20 69 73 20 74 72 65 | togethe|r is tre|
|00000df0| 65 73 20 61 6e 64 20 74 | 68 61 74 20 74 68 65 79 |es and t|hat they|
|00000e00| 20 64 65 66 69 6e 65 64 | 20 74 68 65 20 63 6c 61 | defined| the cla|
|00000e10| 73 73 20 6f 66 20 61 6c | 6c 20 6f 62 6a 65 63 74 |ss of al|l object|
|00000e20| 73 2e 20 20 49 66 20 77 | 65 20 68 61 64 20 61 20 |s. If w|e had a |
|00000e30| 63 61 72 20 74 68 61 74 | 20 77 65 20 77 61 6e 74 |car that| we want|
|00000e40| 65 64 20 74 6f 20 73 65 | 74 20 73 6f 6d 65 20 69 |ed to se|t some i|
|00000e50| 6e 69 74 69 61 6c 20 63 | 6f 6e 64 69 74 69 6f 6e |nitial c|ondition|
|00000e60| 73 20 6f 6e 2c 20 77 6f | 75 6c 64 6e 27 74 20 74 |s on, wo|uldn't t|
|00000e70| 68 65 20 6e 61 74 75 72 | 61 6c 20 70 6c 61 63 65 |he natur|al place|
|00000e80| 20 74 6f 20 64 6f 20 74 | 68 61 74 20 62 65 20 69 | to do t|hat be i|
|00000e90| 6e 20 74 68 65 20 66 61 | 63 74 6f 72 79 20 74 68 |n the fa|ctory th|
|00000ea0| 61 74 20 74 68 65 20 63 | 61 72 20 69 73 20 63 72 |at the c|ar is cr|
|00000eb0| 65 61 74 65 64 3f 20 20 | 54 68 69 73 20 69 73 20 |eated? |This is |
|00000ec0| 74 68 65 20 73 61 6d 65 | 20 77 61 79 20 74 68 61 |the same| way tha|
|00000ed0| 74 20 77 65 20 69 6e 69 | 74 69 61 6c 69 7a 65 20 |t we ini|tialize |
|00000ee0| 6f 62 6a 65 63 74 73 2e | 20 20 57 65 20 73 65 6e |objects.| We sen|
|00000ef0| 64 20 61 20 6d 65 73 73 | 61 67 65 20 74 6f 20 74 |d a mess|age to t|
|00000f00| 68 65 20 66 61 63 74 6f | 72 79 20 61 6e 64 20 61 |he facto|ry and a|
|00000f10| 73 6b 20 69 74 20 74 6f | 20 70 65 72 66 6f 72 6d |sk it to| perform|
|00000f20| 20 73 6f 6d 65 20 74 61 | 73 6b 73 20 66 6f 72 20 | some ta|sks for |
|00000f30| 75 73 20 65 76 65 72 79 | 20 74 69 6d 65 20 69 74 |us every| time it|
|00000f40| 20 63 72 65 61 74 65 73 | 20 61 20 6e 65 77 20 6f | creates| a new o|
|00000f50| 62 6a 65 63 74 2e 0d 03 | ac 0d fc 00 6c 02 22 00 |bject...|....l.".|
|00000f60| 6c 00 0e 02 00 06 30 f7 | ff 00 16 0a 00 f7 2b 20 |l.....0.|......+ |
|00000f70| 6e 65 77 0d 7b 0d 20 09 | 73 65 6c 66 20 3d 20 5b |new.{. .|self = [|
|00000f80| 73 75 70 65 72 20 6e 65 | 77 5d 3b 0d 09 6d 79 49 |super ne|w];..myI|
|00000f90| 6e 74 20 3d 20 31 30 30 | 3b 0d 09 72 65 74 75 72 |nt = 100|;..retur|
|00000fa0| 6e 20 73 65 6c 66 3b 0d | 7d 0d fc 00 5a 02 0a 00 |n self;.|}...Z...|
|00000fb0| 5a 00 0e 01 b0 06 30 f7 | ff 00 15 0a 00 f7 0d 54 |Z.....0.|.......T|
|00000fc0| 68 65 20 66 69 72 73 74 | 20 6c 69 6e 65 20 73 61 |he first| line sa|
|00000fd0| 79 73 20 22 73 65 6e 64 | 20 74 68 65 20 ff 00 16 |ys "send| the ...|
|00000fe0| 0a 01 f7 6e 65 77 f9 00 | f7 ff 00 15 0a 00 f7 20 |...new..|....... |
|00000ff0| 6d 65 73 73 61 67 65 20 | 74 6f 20 74 68 65 20 74 |message |to the t|
|00001000| 68 65 20 73 75 70 65 72 | 63 6c 61 73 73 20 6f 66 |he super|class of|
|00001010| 20 74 68 69 73 20 6f 62 | 6a 65 63 74 73 2e 22 20 | this ob|jects." |
|00001020| 20 49 6e 20 74 68 69 73 | 20 63 61 73 65 2c 20 77 | In this| case, w|
|00001030| 65 20 61 72 65 20 61 20 | 73 75 62 2d 63 6c 61 73 |e are a |sub-clas|
|00001040| 73 20 6f 66 20 74 68 65 | 20 4f 62 6a 65 63 74 20 |s of the| Object |
|00001050| 63 6c 61 73 73 20 73 6f | 20 74 68 65 20 73 75 70 |class so| the sup|
|00001060| 65 72 20 63 6c 61 73 73 | 20 69 73 20 74 68 65 20 |er class| is the |
|00001070| 4f 62 6a 65 63 74 20 63 | 6c 61 73 73 2e 20 20 54 |Object c|lass. T|
|00001080| 68 65 20 77 6f 72 64 20 | ff 00 16 0a 01 f7 73 75 |he word |......su|
|00001090| 70 65 72 f9 00 f7 ff 00 | 15 0a 00 f7 20 69 73 20 |per.....|.... is |
|000010a0| 61 20 72 65 73 65 72 76 | 65 64 20 77 6f 72 64 20 |a reserv|ed word |
|000010b0| 69 6e 20 4f 62 6a 65 63 | 74 69 76 65 20 43 2e 20 |in Objec|tive C. |
|000010c0| 20 42 79 20 73 65 6e 64 | 69 6e 67 20 61 20 6d 65 | By send|ing a me|
|000010d0| 73 73 61 67 65 20 74 6f | 20 ff 00 16 0a 01 f7 73 |ssage to| ......s|
|000010e0| 75 70 65 72 f9 00 f7 ff | 00 15 0a 00 f7 2c 20 77 |uper....|....., w|
|000010f0| 65 20 63 61 6e 20 61 6c | 77 61 79 73 20 74 61 6c |e can al|ways tal|
|00001100| 6b 20 74 6f 20 74 68 65 | 20 73 75 70 65 72 63 6c |k to the| supercl|
|00001110| 61 73 73 20 6f 66 20 61 | 6e 79 20 6f 62 6a 65 63 |ass of a|ny objec|
|00001120| 74 20 77 65 20 61 72 65 | 20 77 6f 72 6b 69 6e 67 |t we are| working|
|00001130| 20 77 69 74 68 2e 20 20 | 54 68 65 20 72 65 73 75 | with. |The resu|
|00001140| 6c 74 20 6f 66 20 74 68 | 65 20 ff 00 16 0a 01 f7 |lt of th|e ......|
|00001150| 5b 73 75 70 65 72 20 6e | 65 77 5d f9 00 f7 ff 00 |[super n|ew].....|
|00001160| 15 0a 00 f7 20 6d 65 73 | 73 61 67 65 20 69 73 20 |.... mes|sage is |
|00001170| 61 20 70 6f 69 6e 74 65 | 72 20 6f 66 20 74 79 70 |a pointe|r of typ|
|00001180| 65 20 69 64 2e 20 20 49 | 74 20 69 73 20 73 74 6f |e id. I|t is sto|
|00001190| 72 65 64 20 69 6e 20 74 | 68 65 20 76 61 72 69 61 |red in t|he varia|
|000011a0| 62 6c 65 20 ff 00 16 0a | 01 f7 73 65 6c 66 f9 00 |ble ....|..self..|
|000011b0| f7 ff 00 15 0a 00 f7 2e | 20 20 ff 00 16 0a 01 f7 |........| ......|
|000011c0| 53 65 6c 66 f9 00 f7 ff | 00 15 0a 00 f7 20 69 73 |Self....|..... is|
|000011d0| 20 61 20 72 65 73 65 72 | 76 65 20 77 6f 72 64 20 | a reser|ve word |
|000011e0| 69 6e 20 4f 62 6a 65 63 | 74 69 76 65 20 43 20 74 |in Objec|tive C t|
|000011f0| 68 61 74 20 68 6f 6c 64 | 73 20 61 20 70 6f 69 6e |hat hold|s a poin|
|00001200| 74 65 72 20 74 6f 20 74 | 68 65 20 6f 62 6a 65 63 |ter to t|he objec|
|00001210| 74 20 74 68 61 74 20 77 | 65 20 61 72 65 20 63 75 |t that w|e are cu|
|00001220| 72 72 65 6e 74 6c 79 20 | 69 6e 2e 20 20 ff 00 16 |rrently |in. ...|
|00001230| 0a 01 f7 4e 65 77 f9 00 | f7 ff 00 15 0a 00 f7 20 |...New..|....... |
|00001240| 6d 65 74 68 6f 64 73 20 | 61 72 65 20 74 68 65 20 |methods |are the |
|00001250| 6f 6e 6c 79 20 70 6c 61 | 63 65 20 69 6e 20 6f 75 |only pla|ce in ou|
|00001260| 72 20 70 72 6f 67 72 61 | 6d 73 20 74 68 61 74 20 |r progra|ms that |
|00001270| ff 00 16 0a 01 f7 73 65 | 6c 66 ff 00 15 0a 00 f7 |......se|lf......|
|00001280| 20 77 69 6c 6c 20 65 76 | 65 72 20 62 65 20 63 68 | will ev|er be ch|
|00001290| 61 6e 67 65 64 2e 20 20 | 20 49 66 20 79 6f 75 20 |anged. | If you |
|000012a0| 65 76 65 72 20 73 65 65 | 20 73 65 6c 66 20 6f 6e |ever see| self on|
|000012b0| 20 74 68 65 20 6c 65 66 | 74 20 73 69 64 65 20 6f | the lef|t side o|
|000012c0| 66 20 74 68 65 20 65 71 | 75 61 6c 20 73 69 67 6e |f the eq|ual sign|
|000012d0| 20 6f 75 74 73 69 64 65 | 20 6f 66 20 61 20 6e 65 | outside| of a ne|
|000012e0| 77 20 6d 65 74 68 6f 64 | 2c 20 77 61 6e 69 6e 67 |w method|, waning|
|000012f0| 20 73 69 67 6e 73 20 73 | 68 6f 75 6c 64 20 67 6f | signs s|hould go|
|00001300| 20 75 70 2e 0d 04 d9 0d | 54 68 65 20 73 65 63 6f | up.....|The seco|
|00001310| 6e 64 20 6c 69 6e 65 20 | 69 6e 69 74 69 61 6c 69 |nd line |initiali|
|00001320| 7a 65 73 20 ff 00 16 0a | 01 f7 6d 79 49 6e 74 f9 |zes ....|..myInt.|
|00001330| 00 f7 ff 00 15 0a 00 f7 | 20 74 6f 20 62 65 20 31 |........| to be 1|
|00001340| 30 30 2e 20 20 54 68 65 | 20 6c 61 73 74 20 6c 69 |00. The| last li|
|00001350| 6e 65 20 72 65 74 75 72 | 6e 73 20 61 20 70 6f 69 |ne retur|ns a poi|
|00001360| 6e 74 65 72 20 74 6f 20 | 74 68 65 20 6f 62 6a 65 |nter to |the obje|
|00001370| 63 74 20 77 65 20 6a 75 | 73 74 20 63 72 65 61 74 |ct we ju|st creat|
|00001380| 65 64 2e 20 20 54 68 69 | 73 20 6c 69 6e 65 20 69 |ed. Thi|s line i|
|00001390| 73 20 72 65 71 75 69 72 | 65 64 20 73 6f 20 6f 74 |s requir|ed so ot|
|000013a0| 68 65 72 20 70 72 6f 67 | 72 61 6d 73 20 74 68 61 |her prog|rams tha|
|000013b0| 74 20 61 73 6b 20 66 6f | 72 20 61 20 6e 65 77 20 |t ask fo|r a new |
|000013c0| 69 6e 73 74 61 6e 63 65 | 20 6f 66 20 6f 75 72 20 |instance| of our |
|000013d0| 6f 62 6a 65 63 74 20 63 | 61 6e 20 72 65 66 65 72 |object c|an refer|
|000013e0| 65 6e 63 65 20 69 74 20 | 62 79 20 6e 61 6d 65 2e |ence it |by name.|
|000013f0| 20 20 49 66 20 79 6f 75 | 20 6e 65 65 64 20 61 20 | If you| need a |
|00001400| 6e 65 77 20 69 6e 73 74 | 61 6e 63 65 20 6f 66 20 |new inst|ance of |
|00001410| 6f 75 72 20 6f 62 6a 65 | 63 74 20 69 6e 20 61 6e |our obje|ct in an|
|00001420| 6f 74 68 65 72 20 70 72 | 6f 67 72 61 6d 2c 20 79 |other pr|ogram, y|
|00001430| 6f 75 20 73 68 6f 75 6c | 64 20 62 65 20 61 62 6c |ou shoul|d be abl|
|00001440| 65 20 74 6f 20 61 64 64 | 20 74 68 65 20 6c 69 6e |e to add| the lin|
|00001450| 65 73 3a 0d ff 00 16 0a | 00 f7 69 64 20 6d 79 4e |es:.....|..id myN|
|00001460| 65 77 48 65 6c 6c 6f 4f | 62 6a 65 63 74 3b 0d 6d |ewHelloO|bject;.m|
|00001470| 79 4e 65 77 48 65 6c 6c | 6f 4f 62 6a 65 63 74 20 |yNewHell|oObject |
|00001480| 3d 20 5b 4d 79 4f 62 6a | 65 63 74 20 6e 65 77 5d |= [MyObj|ect new]|
|00001490| 3b 0d ff 00 15 0a 00 f7 | 0d 59 6f 75 20 6d 69 67 |;.......|.You mig|
|000014a0| 68 74 20 61 73 6b 20 79 | 6f 75 72 73 65 6c 66 2c |ht ask y|ourself,|
|000014b0| 20 77 68 79 20 64 6f 20 | 49 20 68 61 76 65 20 74 | why do |I have t|
|000014c0| 6f 20 75 73 65 20 62 6f | 74 68 65 72 20 73 65 6e |o use bo|ther sen|
|000014d0| 64 69 6e 67 20 74 68 65 | 20 6e 65 77 20 6d 65 74 |ding the| new met|
|000014e0| 68 6f 64 20 74 6f 20 74 | 68 65 20 4f 62 6a 65 63 |hod to t|he Objec|
|000014f0| 74 20 63 6c 61 73 73 3f | 20 20 57 68 79 20 63 61 |t class?| Why ca|
|00001500| 6e 27 74 20 49 20 6a 75 | 73 74 20 75 73 65 20 22 |n't I ju|st use "|
|00001510| 72 61 77 22 20 43 20 74 | 6f 20 61 6c 6c 6f 63 61 |raw" C t|o alloca|
|00001520| 74 65 20 6d 65 6d 6f 72 | 79 20 61 6e 64 20 69 6e |te memor|y and in|
|00001530| 69 74 69 61 6c 69 7a 65 | 20 6d 79 20 6f 62 6a 65 |itialize| my obje|
|00001540| 63 74 3f 20 20 57 68 79 | 20 63 61 6e 27 74 20 49 |ct? Why| can't I|
|00001550| 20 6a 75 73 74 20 6c 65 | 61 76 65 20 6f 75 74 20 | just le|ave out |
|00001560| 74 68 65 20 5b 73 75 70 | 65 72 20 6e 65 77 5d 20 |the [sup|er new] |
|00001570| 6c 69 6e 65 3f 20 20 41 | 6e 64 20 69 6e 64 65 65 |line? A|nd indee|
|00001580| 64 2c 20 79 6f 75 20 74 | 68 65 6f 72 65 74 69 63 |d, you t|heoretic|
|00001590| 61 6c 6c 79 20 63 61 6e | 2e 20 20 42 75 74 20 74 |ally can|. But t|
|000015a0| 68 69 73 20 64 65 66 65 | 61 74 73 20 74 68 65 20 |his defe|ats the |
|000015b0| 77 68 6f 6c 65 20 70 75 | 72 70 6f 73 65 20 6f 66 |whole pu|rpose of|
|000015c0| 20 72 65 2d 75 73 69 6e | 67 20 61 6c 6c 20 74 68 | re-usin|g all th|
|000015d0| 65 20 63 6f 64 65 20 61 | 6c 72 65 61 64 79 20 64 |e code a|lready d|
|000015e0| 6f 6e 65 20 66 6f 72 20 | 75 73 2e 20 20 41 6c 6c |one for |us. All|
|000015f0| 20 6f 66 20 74 68 65 20 | 43 20 63 6f 64 65 20 74 | of the |C code t|
|00001600| 6f 20 66 69 6e 64 20 74 | 68 65 20 73 69 7a 65 20 |o find t|he size |
|00001610| 6f 66 20 6f 62 6a 65 63 | 74 73 20 61 6e 64 20 74 |of objec|ts and t|
|00001620| 68 65 6e 20 61 6c 6c 6f | 63 61 74 65 20 6d 65 6d |hen allo|cate mem|
|00001630| 6f 72 79 20 66 6f 72 20 | 74 68 65 6d 20 69 73 20 |ory for |them is |
|00001640| 61 6c 72 65 61 64 79 20 | 64 6f 6e 65 20 66 6f 72 |already |done for|
|00001650| 20 79 6f 75 2e 20 20 49 | 74 20 69 73 20 69 6e 20 | you. I|t is in |
|00001660| 61 20 63 65 6e 74 72 61 | 6c 69 7a 65 64 20 70 6c |a centra|lized pl|
|00001670| 61 63 65 20 61 6e 64 20 | 74 68 65 20 70 61 72 74 |ace and |the part|
|00001680| 73 20 74 68 61 74 20 74 | 61 6b 65 20 61 20 6c 6f |s that t|ake a lo|
|00001690| 74 20 6f 66 20 74 69 6d | 65 20 68 61 76 65 20 62 |t of tim|e have b|
|000016a0| 65 65 6e 20 6f 70 74 69 | 6d 69 7a 65 64 20 66 6f |een opti|mized fo|
|000016b0| 72 20 70 65 72 66 6f 72 | 6d 61 6e 63 65 2e 20 20 |r perfor|mance. |
|000016c0| 49 66 20 61 20 66 61 73 | 74 65 72 20 6f 72 20 6d |If a fas|ter or m|
|000016d0| 6f 72 65 20 65 66 66 69 | 63 69 65 6e 74 20 6d 65 |ore effi|cient me|
|000016e0| 6d 6f 72 79 20 61 6c 6c | 6f 63 61 74 69 6f 6e 20 |mory all|ocation |
|000016f0| 6d 65 74 68 6f 64 20 63 | 6f 6d 65 73 20 61 6c 6f |method c|omes alo|
|00001700| 6e 67 20 74 68 65 20 70 | 65 6f 70 6c 65 20 61 74 |ng the p|eople at|
|00001710| 20 4e 65 58 54 20 77 69 | 6c 6c 20 6a 75 73 74 20 | NeXT wi|ll just |
|00001720| 69 6e 63 6f 72 70 6f 72 | 61 74 65 20 69 74 20 69 |incorpor|ate it i|
|00001730| 6e 74 6f 20 61 20 73 69 | 6e 67 6c 65 20 70 6c 61 |nto a si|ngle pla|
|00001740| 63 65 20 61 6e 20 61 6c | 6c 20 79 6f 75 72 20 70 |ce an al|l your p|
|00001750| 72 6f 67 72 61 6d 73 20 | 74 68 61 74 20 75 73 65 |rograms |that use|
|00001760| 20 74 68 65 20 20 4f 62 | 6a 65 63 74 20 63 6c 61 | the Ob|ject cla|
|00001770| 73 73 65 73 20 6e 65 77 | 20 6d 65 74 68 6f 64 20 |sses new| method |
|00001780| 77 69 6c 6c 20 73 75 64 | 64 65 6e 6c 79 20 62 65 |will sud|denly be|
|00001790| 63 6f 6d 65 20 66 61 73 | 74 65 72 2e 20 20 54 68 |come fas|ter. Th|
|000017a0| 69 6e 67 73 20 6c 69 6b | 65 20 74 68 69 73 20 72 |ings lik|e this r|
|000017b0| 65 61 6c 6c 79 20 73 74 | 61 72 74 20 61 64 64 69 |eally st|art addi|
|000017c0| 6e 67 20 75 70 20 69 66 | 20 79 6f 75 20 70 6c 61 |ng up if| you pla|
|000017d0| 79 20 62 79 20 74 68 65 | 20 72 75 6c 65 73 2e 0d |y by the| rules..|
|000017e0| 02 ef 0d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |...-----|--------|
|000017f0| 2d 2d 2d 2d 2d 2d 2d 0d | 53 75 6d 6d 61 72 79 0d |-------.|Summary.|
|00001800| 0d ff 00 15 0a 01 f7 57 | 68 65 6e 65 76 65 72 20 |.......W|henever |
|00001810| 79 6f 75 20 6e 65 65 64 | 20 74 6f 20 69 6e 69 74 |you need| to init|
|00001820| 69 61 6c 69 7a 65 20 74 | 68 65 20 73 74 61 74 65 |ialize t|he state|
|00001830| 20 6f 66 20 61 20 6e 65 | 77 20 6f 62 6a 65 63 74 | of a ne|w object|
|00001840| 20 77 68 69 63 68 20 69 | 73 20 6e 6f 74 20 61 20 | which i|s not a |
|00001850| 73 75 62 2d 63 6c 61 73 | 73 20 6f 66 20 56 69 65 |sub-clas|s of Vie|
|00001860| 77 2c 20 61 64 64 20 74 | 68 65 20 66 6f 6c 6c 6f |w, add t|he follo|
|00001870| 77 69 6e 67 20 6c 69 6e | 65 73 20 74 6f 20 74 68 |wing lin|es to th|
|00001880| 65 20 62 65 67 69 6e 6e | 69 6e 67 20 6f 66 20 74 |e beginn|ing of t|
|00001890| 68 65 20 63 6c 61 73 73 | 20 69 6d 70 6c 65 6d 65 |he class| impleme|
|000018a0| 6e 74 61 74 69 6f 6e 20 | 66 69 6c 65 3b 0d ff 00 |ntation |file;...|
|000018b0| 15 0a 00 f7 0d fc 00 6c | 02 22 00 6c 00 0e 02 00 |.......l|.".l....|
|000018c0| 06 30 f7 ff 00 16 0a 00 | f7 2b 20 6e 65 77 0d 7b |.0......|.+ new.{|
|000018d0| 0d 20 09 73 65 6c 66 20 | 3d 20 5b 73 75 70 65 72 |. .self |= [super|
|000018e0| 20 6e 65 77 5d 3b 0d 09 | 2f 2f 20 79 6f 75 72 20 | new];..|// your |
|000018f0| 69 6e 69 74 69 61 6c 69 | 7a 61 74 69 6f 6e 20 67 |initiali|zation g|
|00001900| 6f 65 73 20 68 65 72 65 | 0d 09 72 65 74 75 72 6e |oes here|..return|
|00001910| 20 73 65 6c 66 3b 0d 7d | ff 00 15 0a 00 f7 0d fc | self;.}|........|
|00001920| 00 5a 02 22 00 5a 00 0e | 02 00 06 30 f7 2d 2d 2d |.Z.".Z..|...0.---|
|00001930| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00001940| 2d 0d fc 00 6c 02 22 00 | 6c 00 0e 02 00 06 30 f7 |-...l.".|l.....0.|
|00001950| 0d fc 00 5a 02 0a 00 5a | 00 0e 01 b0 06 30 f7 41 |...Z...Z|.....0.A|
|00001960| 20 73 75 62 63 6c 61 73 | 73 20 6f 66 20 56 69 65 | subclas|s of Vie|
|00001970| 77 20 72 65 71 75 69 72 | 65 73 20 61 20 ff 00 16 |w requir|es a ...|
|00001980| 0a 01 f7 6e 65 77 46 72 | 61 6d 65 3a 3a ff 00 15 |...newFr|ame::...|
|00001990| 0a 00 f7 20 69 6e 73 74 | 65 61 64 20 6f 66 20 61 |... inst|ead of a|
|000019a0| 20 6e 65 77 2e 20 20 54 | 68 69 73 20 69 73 20 63 | new. T|his is c|
|000019b0| 6f 76 65 72 65 64 20 69 | 6e 20 20 63 68 61 70 74 |overed i|n chapt|
|000019c0| 65 72 20 38 3a 20 73 69 | 6d 70 6c 65 20 64 72 61 |er 8: si|mple dra|
|000019d0| 77 69 6e 67 2e 0d 0d 4e | 6f 74 65 20 74 68 61 74 |wing...N|ote that|
|000019e0| 20 79 6f 75 20 64 6f 6e | 27 74 20 68 61 76 65 20 | you don|'t have |
|000019f0| 74 6f 20 64 65 63 6c 61 | 72 65 20 74 68 65 20 6e |to decla|re the n|
|00001a00| 65 77 20 6d 65 74 68 6f | 64 20 69 6e 20 79 6f 75 |ew metho|d in you|
|00001a10| 20 68 65 61 64 65 72 20 | 66 69 6c 65 2e 20 20 54 | header |file. T|
|00001a20| 68 69 73 20 69 73 20 62 | 65 63 61 75 73 65 20 79 |his is b|ecause y|
|00001a30| 6f 75 20 61 72 65 20 6e | 6f 74 20 63 72 65 61 74 |ou are n|ot creat|
|00001a40| 69 6e 67 20 61 20 6d 65 | 74 68 6f 64 20 66 72 6f |ing a me|thod fro|
|00001a50| 6d 20 73 63 72 61 74 63 | 68 2c 20 79 6f 75 20 61 |m scratc|h, you a|
|00001a60| 72 65 20 73 69 6d 70 6c | 79 20 61 64 64 69 6e 67 |re simpl|y adding|
|00001a70| 20 74 6f 20 74 68 65 20 | 65 78 69 73 74 69 6e 67 | to the |existing|
|00001a80| 20 6e 65 77 20 6d 65 74 | 68 6f 64 2e 20 20 54 68 | new met|hod. Th|
|00001a90| 65 20 61 72 67 75 6d 65 | 6e 74 73 20 61 6e 64 20 |e argume|nts and |
|00001aa0| 72 65 74 75 72 6e 65 64 | 20 76 61 6c 75 65 73 20 |returned| values |
|00001ab0| 6d 75 73 74 20 74 68 75 | 73 20 62 65 20 74 68 65 |must thu|s be the|
|00001ac0| 20 73 61 6d 65 20 61 73 | 20 69 6e 20 74 68 65 20 | same as| in the |
|00001ad0| 0d 00 d5 0d 43 6f 6e 74 | 65 6e 74 73 20 6f 66 20 |....Cont|ents of |
|00001ae0| 4d 79 4f 62 6a 65 63 74 | 2e 68 0d 0d fc 00 7e 02 |MyObject|.h....~.|
|00001af0| 0a 00 7e 00 0e 02 88 06 | 30 f7 ff 00 16 0a 00 f7 |..~.....|0.......|
|00001b00| 2f 2a 20 47 65 6e 65 72 | 61 74 65 64 20 62 79 20 |/* Gener|ated by |
|00001b10| 49 6e 74 65 72 66 61 63 | 65 20 42 75 69 6c 64 65 |Interfac|e Builde|
|00001b20| 72 20 2a 2f 0d 0d 23 69 | 6d 70 6f 72 74 20 3c 6f |r */..#i|mport <o|
|00001b30| 62 6a 63 2f 4f 62 6a 65 | 63 74 2e 68 3e 0d 0d 40 |bjc/Obje|ct.h>..@|
|00001b40| 69 6e 74 65 72 66 61 63 | 65 20 4d 79 4f 62 6a 65 |interfac|e MyObje|
|00001b50| 63 74 3a 4f 62 6a 65 63 | 74 0d 7b 0d 09 ff 00 16 |ct:Objec|t.{.....|
|00001b60| 0a 01 f7 69 6e 74 20 6d | 79 49 6e 74 3b ff 00 16 |...int m|yInt;...|
|00001b70| 0a 00 f7 0d 7d 0d 0d 2b | 20 6e 65 77 3b 0d 2d 20 |....}..+| new;.- |
|00001b80| 65 76 65 6e 74 31 3a 73 | 65 6e 64 65 72 3b 0d 2d |event1:s|ender;.-|
|00001b90| 20 65 76 65 6e 74 32 3a | 73 65 6e 64 65 72 3b 0d | event2:|sender;.|
|00001ba0| 0d 40 65 6e 64 0d 0d 0d | 01 cf 0d fc 00 59 02 0a |.@end...|.....Y..|
|00001bb0| 00 59 00 0e 01 b0 06 30 | f7 ff 00 15 0a 00 f7 43 |.Y.....0|.......C|
|00001bc0| 6f 6e 74 65 6e 74 73 20 | 6f 66 20 4d 79 4f 62 6a |ontents |of MyObj|
|00001bd0| 65 63 74 2e 6d ff 00 16 | 0a 00 f7 0d fc 00 62 02 |ect.m...|......b.|
|00001be0| 0a 00 62 00 0e 01 f0 08 | 06 30 f7 0d fc 00 90 02 |..b.....|.0......|
|00001bf0| 0a 00 90 00 0e 02 d4 06 | 30 f7 2f 2a 20 47 65 6e |........|0./* Gen|
|00001c00| 65 72 61 74 65 64 20 62 | 79 20 49 6e 74 65 72 66 |erated b|y Interf|
|00001c10| 61 63 65 20 42 75 69 6c | 64 65 72 20 2a 2f 0d 0d |ace Buil|der */..|
|00001c20| 23 69 6d 70 6f 72 74 20 | 22 4d 79 4f 62 6a 65 63 |#import |"MyObjec|
|00001c30| 74 2e 68 22 0d 23 69 6d | 70 6f 72 74 20 3c 73 74 |t.h".#im|port <st|
|00001c40| 64 69 6f 2e 68 3e 0d 0d | 40 69 6d 70 6c 65 6d 65 |dio.h>..|@impleme|
|00001c50| 6e 74 61 74 69 6f 6e 20 | 4d 79 4f 62 6a 65 63 74 |ntation |MyObject|
|00001c60| 0d 0d ff 00 16 0a 01 f7 | 2b 20 6e 65 77 20 7b 0d |........|+ new {.|
|00001c70| 09 73 65 6c 66 20 3d 20 | 5b 73 75 70 65 72 20 6e |.self = |[super n|
|00001c80| 65 77 5d 3b 0d 09 6d 79 | 49 6e 74 20 3d 20 31 30 |ew];..my|Int = 10|
|00001c90| 30 3b 0d 09 72 65 74 75 | 72 6e 20 73 65 6c 66 3b |0;..retu|rn self;|
|00001ca0| 0d 7d 0d ff 00 16 0a 00 | f7 0d 2d 20 65 76 65 6e |.}......|..- even|
|00001cb0| 74 31 3a 73 65 6e 64 65 | 72 0d 7b 0d ff 00 16 0a |t1:sende|r.{.....|
|00001cc0| 01 f7 09 6d 79 49 6e 74 | 2b 2b 3b 0d 09 70 72 69 |...myInt|++;..pri|
|00001cd0| 6e 74 66 28 22 6d 79 49 | 6e 74 2b 2b 20 3d 20 25 |ntf("myI|nt++ = %|
|00001ce0| 64 5c 6e 22 2c 20 6d 79 | 49 6e 74 29 3b 0d ff 00 |d\n", my|Int);...|
|00001cf0| 16 0a 00 f7 09 72 65 74 | 75 72 6e 20 73 65 6c 66 |.....ret|urn self|
|00001d00| 3b 0d 7d 0d 0d 2d 20 65 | 76 65 6e 74 32 3a 73 65 |;.}..- e|vent2:se|
|00001d10| 6e 64 65 72 0d 7b 0d ff | 00 16 0a 01 f7 09 6d 79 |nder.{..|......my|
|00001d20| 49 6e 74 2d 2d 3b 0d 09 | 70 72 69 6e 74 66 28 22 |Int--;..|printf("|
|00001d30| 6d 79 49 6e 74 2d 2d 20 | 3d 20 25 64 5c 6e 22 2c |myInt-- |= %d\n",|
|00001d40| 20 6d 79 49 6e 74 29 3b | 0d ff 00 16 0a 00 f7 09 | myInt);|........|
|00001d50| 72 65 74 75 72 6e 20 73 | 65 6c 66 3b 0d 7d 0d 0d |return s|elf;.}..|
|00001d60| 40 65 6e 64 0d ff 00 15 | 0a 00 f7 0d fc 00 5a 02 |@end....|......Z.|
|00001d70| 0a 00 5a 00 0e 06 30 f7 | 0d 03 35 46 6f 72 20 61 |..Z...0.|..5For a|
|00001d80| 64 76 61 6e 63 65 64 20 | 72 65 61 64 65 72 73 3a |dvanced |readers:|
|00001d90| 0d 0d 54 68 65 72 65 20 | 61 72 65 20 74 69 6d 65 |..There |are time|
|00001da0| 73 20 77 68 65 6e 20 79 | 6f 75 20 61 6c 73 6f 20 |s when y|ou also |
|00001db0| 77 61 6e 74 20 74 6f 20 | 73 65 70 61 72 61 74 65 |want to |separate|
|00001dc0| 20 69 6e 69 74 69 61 6c | 69 7a 61 74 69 6f 6e 20 | initial|ization |
|00001dd0| 73 74 65 70 73 20 66 72 | 6f 6d 20 74 68 65 20 6e |steps fr|om the n|
|00001de0| 65 77 20 6d 65 74 68 6f | 64 2e 20 20 46 6f 72 20 |ew metho|d. For |
|00001df0| 65 78 61 6d 70 6c 65 20 | 69 66 20 79 6f 75 20 68 |example |if you h|
|00001e00| 61 76 65 20 61 6e 20 6f | 62 6a 65 63 74 20 74 68 |ave an o|bject th|
|00001e10| 61 74 20 79 6f 75 20 77 | 61 6e 74 20 74 6f 20 72 |at you w|ant to r|
|00001e20| 65 73 65 74 20 74 6f 20 | 61 20 73 65 74 20 6f 66 |eset to |a set of|
|00001e30| 20 64 65 66 61 75 6c 74 | 20 76 61 6c 75 65 73 20 | default| values |
|00001e40| 79 6f 75 20 77 6f 75 6c | 64 20 6c 69 6b 65 20 74 |you woul|d like t|
|00001e50| 6f 20 69 6e 69 74 69 61 | 6c 69 7a 65 20 74 68 65 |o initia|lize the|
|00001e60| 20 73 74 61 74 65 20 6f | 66 20 74 68 65 20 6f 62 | state o|f the ob|
|00001e70| 6a 65 63 74 20 77 68 65 | 6e 20 69 74 20 63 61 6d |ject whe|n it cam|
|00001e80| 65 20 6f 75 74 20 6f 66 | 20 74 68 65 20 66 61 63 |e out of| the fac|
|00001e90| 74 6f 72 79 20 62 75 74 | 20 6e 6f 74 20 72 65 2d |tory but| not re-|
|00001ea0| 61 6c 6c 6f 63 61 74 65 | 20 74 68 65 20 6d 65 6d |allocate| the mem|
|00001eb0| 6f 72 79 2e 20 20 49 6e | 20 74 68 69 73 20 63 61 |ory. In| this ca|
|00001ec0| 73 65 2c 20 74 68 65 20 | 4f 62 6a 65 63 74 69 76 |se, the |Objectiv|
|00001ed0| 65 20 43 20 63 6f 6e 76 | 65 6e 74 69 6f 6e 20 69 |e C conv|ention i|
|00001ee0| 73 20 74 6f 20 75 73 65 | 20 61 6e 20 ff 00 16 0a |s to use| an ....|
|00001ef0| 01 f7 2d 69 6e 69 74 69 | 61 6c 69 7a 65 ff 00 15 |..-initi|alize...|
|00001f00| 0a 00 f7 20 6d 65 74 68 | 6f 64 f9 03 f7 f4 f9 00 |... meth|od......|
|00001f10| f7 f9 00 f7 2e 20 20 54 | 68 69 73 20 61 6c 6c 6f |..... T|his allo|
|00001f20| 77 73 20 79 6f 75 20 74 | 6f 20 6f 76 65 72 2d 72 |ws you t|o over-r|
|00001f30| 69 64 65 20 6f 74 68 65 | 72 20 6f 62 6a 65 63 74 |ide othe|r object|
|00001f40| 73 20 69 6e 69 74 69 61 | 6c 69 7a 61 74 69 6f 6e |s initia|lization|
|00001f50| 20 63 6f 64 65 2e 20 20 | 59 6f 75 72 20 6e 65 77 | code. |Your new|
|00001f60| 20 77 6f 75 6c 64 20 6c | 6f 6f 6b 20 6c 69 6b 65 | would l|ook like|
|00001f70| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 3a 0d | the fol|lowing:.|
|00001f80| 0d fc 00 6c 02 22 00 6c | 00 0e 02 00 06 30 f7 ff |...l.".l|.....0..|
|00001f90| 00 16 0a 00 f7 2b 20 6e | 65 77 0d 7b 0d 20 09 73 |.....+ n|ew.{. .s|
|00001fa0| 65 6c 66 20 3d 20 5b 73 | 75 70 65 72 20 6e 65 77 |elf = [s|uper new|
|00001fb0| 5d 3b 0d 09 5b 73 65 6c | 66 20 69 6e 69 74 69 61 |];..[sel|f initia|
|00001fc0| 6c 69 7a 65 5d 3b 0d 09 | 72 65 74 75 72 6e 20 73 |lize];..|return s|
|00001fd0| 65 6c 66 3b 0d 7d ff 00 | 15 0a 00 f7 0d fc 00 5a |elf;.}..|.......Z|
|00001fe0| 02 0a 00 5a 00 0e 06 30 | f7 0d fc 00 6c 02 22 00 |...Z...0|....l.".|
|00001ff0| 6c 00 0e 02 00 06 30 f7 | ff 00 16 0a 00 f7 2d 69 |l.....0.|......-i|
|00002000| 6e 69 74 69 61 6c 69 7a | 65 0d 7b 0d 09 2f 2f 20 |nitializ|e.{..// |
|00002010| 74 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 75 73 |the foll|owing us|
|00002020| 65 64 20 6f 6e 6c 79 20 | 69 66 20 74 68 65 20 73 |ed only |if the s|
|00002030| 75 70 65 72 20 63 6c 61 | 73 73 20 68 61 73 20 61 |uper cla|ss has a|
|00002040| 6e 20 69 6e 69 74 69 61 | 6c 69 7a 65 0d 20 09 5b |n initia|lize. .[|
|00002050| 73 75 70 65 72 20 69 6e | 69 74 69 61 6c 69 7a 65 |super in|itialize|
|00002060| 5d 3b 0d 09 2f 2f 20 61 | 64 64 20 79 6f 75 72 20 |];..// a|dd your |
|00002070| 6f 77 6e 20 69 6e 69 74 | 69 61 6c 69 7a 61 74 69 |own init|ializati|
|00002080| 6f 6e 20 63 6f 64 65 20 | 68 65 72 65 0d 09 72 65 |on code |here..re|
|00002090| 74 75 72 6e 20 73 65 6c | 66 3b 0d 7d ff 00 15 0a |turn sel|f;.}....|
|000020a0| 00 f7 0d fc 00 5a 02 0a | 00 5a 00 0e 06 30 f7 0d |.....Z..|.Z...0..|
|000020b0| 02 32 45 78 65 72 63 69 | 73 65 73 0d 0d 36 2d 31 |.2Exerci|ses..6-1|
|000020c0| 2e 20 20 49 66 20 79 6f | 75 20 61 64 64 65 64 20 |. If yo|u added |
|000020d0| 74 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 6c 69 |the foll|owing li|
|000020e0| 6e 65 20 69 6e 20 74 68 | 65 20 6e 65 77 20 6d 65 |ne in th|e new me|
|000020f0| 74 68 6f 64 3a 0d fc 00 | 7e 02 0a 00 7e 00 0e 06 |thod:...|~...~...|
|00002100| 30 f7 0d fc 00 7e 02 0a | 00 7e 00 0e 02 88 06 30 |0....~..|.~.....0|
|00002110| f7 ff 00 16 0a 00 f7 2b | 20 6e 65 77 20 7b 0d 09 |.......+| new {..|
|00002120| 73 65 6c 66 20 3d 20 5b | 73 75 70 65 72 20 6e 65 |self = [|super ne|
|00002130| 77 5d 3b 0d 09 6d 79 49 | 6e 74 20 3d 20 31 30 30 |w];..myI|nt = 100|
|00002140| 3b 0d 09 ff 00 16 0a 01 | f7 70 72 69 6e 74 66 28 |;.......|.printf(|
|00002150| 22 6e 65 77 3a 20 6d 79 | 49 6e 74 20 69 6e 69 74 |"new: my|Int init|
|00002160| 69 61 6c 69 7a 65 64 20 | 74 6f 20 25 64 5c 6e 22 |ialized |to %d\n"|
|00002170| 2c 20 6d 79 49 6e 74 29 | 3b ff 00 16 0a 00 f7 0d |, myInt)|;.......|
|00002180| 09 72 65 74 75 72 6e 20 | 73 65 6c 66 3b 0d 7d 0d |.return |self;.}.|
|00002190| fc 00 7e 02 0a 00 7e 00 | 0e 02 d4 06 30 f7 0d ff |..~...~.|....0...|
|000021a0| 00 15 0a 00 f7 57 68 65 | 6e 20 77 6f 75 6c 64 20 |.....Whe|n would |
|000021b0| 79 6f 75 20 65 78 70 65 | 63 74 20 74 68 65 20 70 |you expe|ct the p|
|000021c0| 72 69 6e 74 66 20 74 6f | 20 62 65 20 65 78 65 63 |rintf to| be exec|
|000021d0| 75 74 65 64 3f 20 20 49 | 66 20 79 6f 75 20 73 61 |uted? I|f you sa|
|000021e0| 69 64 20 77 68 65 6e 20 | 74 68 65 20 70 72 6f 67 |id when |the prog|
|000021f0| 72 61 6d 20 73 74 61 72 | 74 73 20 75 70 20 6f 72 |ram star|ts up or|
|00002200| 20 22 6c 61 75 6e 63 68 | 65 73 22 20 79 6f 75 20 | "launch|es" you |
|00002210| 77 6f 75 6c 64 20 62 65 | 20 72 69 67 68 74 2e 0d |would be| right..|
|00002220| 0d fc 00 5b 02 0a 00 5b | 00 0e 02 d4 06 30 f7 36 |...[...[|.....0.6|
|00002230| 2d 32 20 54 68 65 72 65 | 20 61 72 65 20 73 65 76 |-2 There| are sev|
|00002240| 65 72 61 6c 20 77 61 79 | 73 20 74 6f 20 69 6e 69 |eral way|s to ini|
|00002250| 74 69 61 6c 69 7a 65 20 | 63 6f 6d 70 6c 65 78 20 |tialize |complex |
|00002260| 43 20 64 61 74 61 20 73 | 74 72 75 63 74 75 72 65 |C data s|tructure|
|00002270| 73 2e 20 20 57 68 61 74 | 20 68 61 70 70 65 6e 73 |s. What| happens|
|00002280| 20 69 66 20 79 6f 75 20 | 75 73 65 20 61 20 73 74 | if you |use a st|
|00002290| 72 69 6e 67 20 61 73 20 | 61 6e 20 69 6e 73 74 61 |ring as |an insta|
|000022a0| 6e 63 65 20 76 61 72 69 | 61 62 6c 65 3f 20 20 57 |nce vari|able? W|
|000022b0| 68 61 74 20 61 62 6f 75 | 74 20 61 20 6d 61 74 72 |hat abou|t a matr|
|000022c0| 69 78 20 6f 66 20 69 6e | 74 65 67 65 72 73 3f 20 |ix of in|tegers? |
|000022d0| 20 53 65 65 20 61 20 63 | 6f 70 79 20 6f 66 20 41 | See a c|opy of A|
|000022e0| 20 43 20 0d 00 54 24 00 | 06 bd 00 2a a6 00 02 86 | C ..T$.|...*....|
|000022f0| 00 00 a7 00 02 e8 02 14 | 64 00 0b b7 00 b7 04 00 |........|d.......|
|00002300| 03 71 00 54 64 00 0f 57 | 00 e7 24 00 13 05 00 ef |.q.Td..W|..$.....|
|00002310| 64 00 17 e0 01 28 04 00 | 05 14 00 54 74 00 1a d1 |d....(..|...Tt...|
|00002320| 01 0a 74 00 1b a8 01 cf | 74 00 1d 79 00 57 85 00 |..t.....|t..y.W..|
|00002330| 03 0b 00 f0 64 00 20 b0 | 00 e0 00 7a 0d ff 00 15 |....d. .|...z....|
|00002340| 0a 00 f7 4f 62 6a 65 63 | 74 20 42 61 73 65 64 20 |...Objec|t Based |
|00002350| 43 6f 6d 70 75 74 69 6e | 67 3a 20 41 20 4e 65 78 |Computin|g: A Nex|
|00002360| 74 53 74 65 70 20 54 75 | 74 6f 72 69 61 6c 20 61 |tStep Tu|torial a|
|00002370| 6e 64 20 43 6f 6f 6b 62 | 6f 6f 6b 20 2d 20 56 65 |nd Cookb|ook - Ve|
|00002380| 72 73 69 6f 6e 20 31 2e | 35 20 2d 20 44 47 4d 0d |rsion 1.|5 - DGM.|
|00002390| 43 68 61 70 74 65 72 20 | 37 3a 49 6e 69 74 69 61 |Chapter |7:Initia|
|000023a0| 6c 69 7a 69 6e 67 20 4f | 62 6a 65 63 74 73 ff 00 |lizing O|bjects..|
|000023b0| 15 0c 00 f7 0d 0d 00 2d | 0d ff 00 15 0a 00 f7 50 |.......-|.......P|
|000023c0| 61 67 65 20 37 2d fd 00 | f7 20 20 20 20 20 20 20 |age 7-..|. |
|000023d0| fd 01 f7 20 20 20 20 20 | 20 20 fd 02 f7 ff 00 15 |... | ......|
|000023e0| 0c 00 f7 0d 0d 00 54 24 | 00 06 bd 00 2a a6 00 23 |......T$|....*..#|
|000023f0| 3a 00 00 a7 00 23 b6 02 | 14 64 00 0b b7 00 b7 04 |:....#..|.d......|
|00002400| 00 03 71 00 54 64 00 0f | 57 00 e7 24 00 13 05 00 |..q.Td..|W..$....|
|00002410| ef 64 00 17 e0 01 28 04 | 00 05 14 00 54 74 00 1a |.d....(.|....Tt..|
|00002420| d1 01 0a 74 00 1b a8 01 | cf 74 00 1d 79 00 57 85 |...t....|.t..y.W.|
|00002430| 00 03 0b 00 f0 64 00 20 | b0 00 e0 00 18 04 00 02 |.....d. |........|
|00002440| 00 00 38 04 00 02 06 00 | 38 24 00 23 3a 00 39 24 |..8.....|8$.#:.9$|
|00002450| 00 23 b6 00 2b 04 f7 f5 | f6 ff 00 15 24 01 f7 43 |.#..+...|....$..C|
|00002460| 68 61 70 74 65 72 20 37 | 0d 49 6e 69 74 69 61 6c |hapter 7|.Initial|
|00002470| 69 7a 69 6e 67 20 4f 62 | 6a 65 63 74 73 3a 20 41 |izing Ob|jects: A|
|00002480| 20 54 6f 75 72 20 6f 66 | 20 74 68 65 20 46 61 63 | Tour of| the Fac|
|00002490| 74 6f 72 79 ff 00 15 0c | 00 f7 0d 0d 0d 0d 0d 0d |tory....|........|
|000024a0| 0d 0d 0d 0d ff 00 15 0c | 02 f7 0d 0d ff 00 15 24 |........|.......$|
|000024b0| 01 f7 0d ff 00 15 0a 00 | f7 66 61 63 b7 74 6f b7 |........|.fac.to.|
|000024c0| 72 79 20 5c 27 66 61 6b | 2d 74 28 65 2d 29 72 65 |ry \'fak|-t(e-)re|
|000024d0| c5 5c 20 6e 2c 20 20 70 | 6c 20 2d 72 69 65 73 0d |.\ n, p|l -ries.|
|000024e0| 28 31 35 38 32 29 0d 31 | 3a 20 61 20 73 74 61 74 |(1582).1|: a stat|
|000024f0| 69 6f 6e 20 77 68 65 72 | 65 20 72 65 73 69 64 65 |ion wher|e reside|
|00002500| 6e 74 20 66 61 63 74 6f | 72 73 20 74 72 61 64 65 |nt facto|rs trade|
|00002510| 0d 32 61 3a 20 61 20 62 | 75 69 6c 64 69 6e 67 20 |.2a: a b|uilding |
|00002520| 6f 72 20 73 65 74 20 6f | 66 20 62 75 69 6c 64 69 |or set o|f buildi|
|00002530| 6e 67 73 20 77 69 74 68 | 20 66 61 63 69 6c 69 74 |ngs with| facilit|
|00002540| 69 65 73 20 66 6f 72 20 | 6d 61 6e 75 66 61 63 74 |ies for |manufact|
|00002550| 75 72 69 6e 67 0d 62 3a | 20 74 68 65 20 73 65 61 |uring.b:| the sea|
|00002560| 74 20 6f 66 20 73 6f 6d | 65 20 6b 69 6e 64 20 6f |t of som|e kind o|
|00002570| 66 20 70 72 6f 64 75 63 | 74 69 6f 6e 20 28 74 68 |f produc|tion (th|
|00002580| 65 20 76 69 63 65 20 66 | 61 63 74 6f 72 69 65 73 |e vice f|actories|
|00002590| 20 6f 66 20 74 68 65 20 | 73 6c 75 6d 73 29 0d d0 | of the |slums)..|
|000025a0| 20 66 61 63 b7 74 6f b7 | 72 79 b7 6c 69 6b 65 20 | fac.to.|ry.like |
|000025b0| 5c 2d 2c 6c f0 05 c5 6b | 5c 20 61 64 6a 20 0d 0d |\-,l...k|\ adj ..|
|000025c0| 0d f9 00 f7 57 65 20 68 | 61 76 65 20 6e 6f 77 20 |....We h|ave now |
|000025d0| 69 6e 74 72 6f 64 75 63 | 65 64 20 74 68 65 20 66 |introduc|ed the f|
|000025e0| 6f 75 72 20 66 75 6e 64 | 61 6d 65 6e 74 61 6c 20 |our fund|amental |
|000025f0| 74 65 63 68 6e 69 71 75 | 65 73 20 75 73 65 64 20 |techniqu|es used |
|00002600| 62 79 20 6f 62 6a 65 63 | 74 20 62 61 73 65 64 20 |by objec|t based |
|00002610| 63 6f 6d 70 75 74 69 6e | 67 20 73 79 73 74 65 6d |computin|g system|
|00002620| 73 20 74 6f 20 61 6c 6c | 6f 77 20 79 6f 75 20 74 |s to all|ow you t|
|00002630| 6f 20 62 65 20 70 72 6f | 64 75 63 74 69 76 65 2e |o be pro|ductive.|
|00002640| 20 20 57 65 20 77 69 6c | 6c 20 6e 6f 77 20 74 61 | We wil|l now ta|
|00002650| 6b 65 20 61 20 62 69 74 | 20 6d 6f 72 65 20 64 65 |ke a bit| more de|
|00002660| 74 61 69 6c 65 64 20 6c | 6f 6f 6b 20 61 74 20 68 |tailed l|ook at h|
|00002670| 6f 77 20 74 6f 20 67 65 | 74 20 67 6f 69 6e 67 20 |ow to ge|t going |
|00002680| 63 72 65 61 74 69 6e 67 | 20 6f 62 6a 65 63 74 73 |creating| objects|
|00002690| 2e 20 20 4f 6e 65 20 6f | 66 20 74 68 65 20 66 69 |. One o|f the fi|
|000026a0| 72 73 74 20 74 68 69 6e | 67 73 20 77 65 20 6f 66 |rst thin|gs we of|
|000026b0| 74 65 6e 20 6e 65 65 64 | 20 74 6f 20 64 6f 20 77 |ten need| to do w|
|000026c0| 68 65 6e 20 63 72 65 61 | 74 69 6e 67 20 61 20 6e |hen crea|ting a n|
|000026d0| 65 77 20 6f 62 6a 65 63 | 74 20 69 73 20 73 65 74 |ew objec|t is set|
|000026e0| 20 61 6e 20 69 6e 69 74 | 69 61 6c 20 76 61 6c 75 | an init|ial valu|
|000026f0| 65 20 61 73 73 6f 63 69 | 61 74 65 64 20 77 69 74 |e associ|ated wit|
|00002700| 68 20 61 6e 20 6f 62 6a | 65 63 74 2e 20 20 54 68 |h an obj|ect. Th|
|00002710| 65 20 76 61 6c 75 65 73 | 20 69 6e 73 69 64 65 20 |e values| inside |
|00002720| 61 6e 20 6f 62 6a 65 63 | 74 20 61 72 65 20 73 74 |an objec|t are st|
|00002730| 6f 72 65 64 20 69 6e 20 | 69 6e 73 74 61 6e 63 65 |ored in |instance|
|00002740| 20 76 61 72 69 61 62 6c | 65 73 2e 20 20 54 68 65 | variabl|es. The|
|00002750| 79 20 61 72 65 20 74 68 | 65 20 69 6e 74 65 67 65 |y are th|e intege|
|00002760| 72 73 2c 20 66 6c 6f 61 | 74 69 6e 67 20 70 6f 69 |rs, floa|ting poi|
|00002770| 6e 74 20 6e 75 6d 62 65 | 72 73 2c 20 73 74 72 69 |nt numbe|rs, stri|
|00002780| 6e 67 73 20 61 6e 64 20 | 6f 74 68 65 72 20 64 61 |ngs and |other da|
|00002790| 74 61 20 73 74 72 75 63 | 74 75 72 65 73 20 69 6e |ta struc|tures in|
|000027a0| 73 69 64 65 20 6f 75 72 | 20 62 6c 61 63 6b 20 62 |side our| black b|
|000027b0| 6f 78 65 73 2e 20 20 49 | 6e 20 43 68 61 70 74 65 |oxes. I|n Chapte|
|000027c0| 72 20 33 20 77 65 20 63 | 72 65 61 74 65 64 20 61 |r 3 we c|reated a|
|000027d0| 6e 20 6f 62 6a 65 63 74 | 20 74 68 61 74 20 70 72 |n object| that pr|
|000027e0| 69 6e 74 65 64 20 6f 75 | 74 20 74 68 65 20 77 6f |inted ou|t the wo|
|000027f0| 72 64 73 20 22 68 65 6c | 6c 6f 20 77 6f 72 6c 64 |rds "hel|lo world|
|00002800| 22 20 77 68 65 6e 20 61 | 20 62 75 74 74 6f 6e 20 |" when a| button |
|00002810| 77 61 73 20 70 72 65 73 | 73 65 64 2e 20 20 45 78 |was pres|sed. Ex|
|00002820| 65 72 63 69 73 65 20 66 | 6f 75 72 20 73 75 67 67 |ercise f|our sugg|
|00002830| 65 73 74 65 64 20 63 72 | 65 61 74 69 6e 67 20 61 |ested cr|eating a|
|00002840| 6e 20 6f 62 6a 65 63 74 | 20 74 68 61 74 20 77 6f |n object| that wo|
|00002850| 75 6c 64 20 68 61 76 65 | 20 74 77 6f 20 61 63 74 |uld have| two act|
|00002860| 69 6f 6e 20 6d 65 74 68 | 6f 64 73 2e 20 20 4f 6e |ion meth|ods. On|
|00002870| 65 20 77 6f 75 6c 64 20 | 69 6e 63 72 65 6d 65 6e |e would |incremen|
|00002880| 74 20 74 68 65 20 69 6e | 74 65 72 6e 61 6c 20 73 |t the in|ternal s|
|00002890| 74 61 74 65 20 6f 66 20 | 61 6e 20 6f 62 6a 65 63 |tate of |an objec|
|000028a0| 74 20 61 6e 64 20 6f 6e | 65 20 77 6f 75 6c 64 20 |t and on|e would |
|000028b0| 64 65 63 72 65 6d 65 6e | 74 20 74 68 65 20 73 74 |decremen|t the st|
|000028c0| 61 74 65 20 6f 66 20 61 | 6e 20 6f 62 6a 65 63 74 |ate of a|n object|
|000028d0| 2e 20 20 42 75 74 20 77 | 68 61 74 20 69 66 20 77 |. But w|hat if w|
|000028e0| 65 20 77 61 6e 74 65 64 | 20 74 6f 20 73 74 61 72 |e wanted| to star|
|000028f0| 74 20 74 68 65 20 69 6e | 69 74 69 61 6c 20 73 74 |t the in|itial st|
|00002900| 61 74 65 20 6f 66 20 74 | 68 65 20 6f 62 6a 65 63 |ate of t|he objec|
|00002910| 74 20 61 74 20 61 20 76 | 61 6c 75 65 20 6f 74 68 |t at a v|alue oth|
|00002920| 65 72 20 74 68 65 6e 20 | 7a 65 72 6f 3f 20 20 49 |er then |zero? I|
|00002930| 66 20 77 65 20 70 75 74 | 20 74 68 65 20 66 6f 6c |f we put| the fol|
|00002940| 6c 6f 77 69 6e 67 20 6c | 69 6e 65 73 3a 0d 00 54 |lowing l|ines:..T|
|00002950| 24 00 24 55 00 2a a6 00 | 23 3a 00 00 a7 00 23 b6 |$.$U.*..|#:....#.|
|00002960| 02 14 64 00 0b b7 00 b7 | 04 00 03 71 00 54 64 00 |..d.....|...q.Td.|
|00002970| 0f 57 00 e7 24 00 13 05 | 00 ef 64 00 17 e0 01 28 |.W..$...|..d....(|
|00002980| 04 00 05 14 00 54 74 00 | 1a d1 01 0a 74 00 1b a8 |.....Tt.|....t...|
|00002990| 01 cf 74 00 1d 79 00 57 | 85 00 03 0b 00 f0 64 00 |..t..y.W|......d.|
|000029a0| 20 b0 00 e0 | | ... | |
+--------+-------------------------+-------------------------+--------+--------+