home *** CD-ROM | disk | FTP | other *** search
- // Main program for testing the Fruit and Apple classes
-
- #import "Fruit.h"
- #import "Apple.h"
-
- main ( argc, argv )
- int argc;
- char *argv[];
- {
- id aFruit, anApple;
-
- // Create a Fruit instance
- aFruit = [ Fruit create ];
- printf("aFruit, address %lx\n\t The diameter is %d and color is %s,\n",
- aFruit, //the address of AFruit
- [ aFruit diameter ],
- [ aFruit color ]);
-
- // grow the Fruit
- [ aFruit grow ];
- printf("aFruit, address %lx\n\t The diameter is %d and color is %s.\n",
- aFruit,
- [ aFruit diameter ],
- [ aFruit color ]);
-
- // Create an Apple instance
- anApple = [ Apple create ];
- printf("anApple, address %lx\n\t The diameter is %d and color is %s,\n",
- anApple,
- [ anApple diameter ], // address of anApple
- [ anApple color ],
- [ anApple flavor ]);
-
- // Change the apple's color flavor and diameter
- [ [ [ anApple color: "red" ] flavor: "Macintosh" ] diameter: 7 ] ;
- printf("anApple, address %lx\n\t The diameter is %d and color is %s.\n",
- anApple, // address of anApple
- [ anApple diameter ],
- [ anApple color ],
- [ anApple flavor ]);
-
- } // end of program
-