home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / OOP_Course / Labs / Fruit / fruitMain.m < prev    next >
Encoding:
Text File  |  1993-01-18  |  1.7 KB  |  58 lines

  1. //  LAB DEMO:  Fruit and Apple classes
  2.  
  3. // Main program for testing the Fruit and Apple classes
  4.  
  5. #import "Fruit.h"
  6. #import "Apple.h"
  7.  
  8. main ( argc, argv )
  9. int argc;
  10. char *argv[];
  11. {
  12.     id aFruit, anApple;
  13.  
  14.     printf ("\nCreate a Fruit instance...\n");
  15.         aFruit = [[Fruit alloc] init];    //allocate and initialize
  16.         printf("aFruit, address %lx\n\t The diameter is %d and color is %s.\n",
  17.             aFruit,                //address of aFruit
  18.             [aFruit diameter],        //diameter of aFruit
  19.             [aFruit color]);        //color of aFruit
  20.  
  21.     printf ("Grow the Fruit...\n");
  22.         [aFruit grow];
  23.         printf("aFruit, address %lx\n\t The diameter is %d and color is %s.\n",
  24.             aFruit,                //address of aFruit
  25.             [aFruit diameter],
  26.             [aFruit color]);
  27.         
  28.     printf ("Create an Apple instance...\n");
  29.         anApple = [[Apple alloc] init];
  30.         printf("anApple, address %lx\n\t The diameter is %d, color is %s, and flavor is %s.\n",
  31.             anApple,              // address of anApple
  32.             [anApple diameter],
  33.             [anApple color],
  34.             [anApple flavor]);
  35.  
  36.     printf ("Change the apple's color, flavor, and diameter...\n");
  37.         [[[anApple setColor:"bright red"] setFlavor:"Macintosh"] setDiameter: 7] ;
  38.         printf("anApple, address %lx\n\t The diameter is %d, color is %s, and flavor is %s.\n",
  39.             anApple,              // address of anApple
  40.             [anApple diameter],
  41.             [anApple color],
  42.             [anApple flavor]);
  43.  
  44.     printf ("Grow the apple...\n");
  45.         [anApple grow];
  46.         printf("anApple, address %lx\n\t The diameter is %d, color is %s, and flavor is %s.\n",
  47.             anApple,              // address of anApple
  48.             [anApple diameter],
  49.             [anApple color],
  50.             [anApple flavor]);
  51.  
  52. /* Additions to Create, Change, and Grow a Banana. */
  53.  
  54. //  You are to add code here, similar to above, to do this.
  55.  
  56.  
  57. } // end of program
  58.