home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / os2tk20 / c / samples / animals / dog.cs_ / DOG.CSC
Encoding:
Text File  |  1992-07-15  |  2.1 KB  |  79 lines

  1. #   @(#)dog.csc 1.3 2/3/92 20:39:47 [2/3/92] (c)IBM Corp. 1992
  2.  
  3. -- Copyright (c) International Business Machines Corporation
  4. --         1991, 1992
  5.  
  6. include "dogmeta.sc"
  7. include "animal.sc"
  8.  
  9. class: Dog,
  10.   local;
  11.  
  12. metaclass: DogFactory;
  13.  
  14. parent: Animal;
  15.  
  16. data:
  17.   char *breed;
  18.   char *color;
  19.  
  20. methods:
  21.  
  22. group: SetMethods;
  23.  
  24.    void setBreed(char *myBreed);
  25. -- Set the Breed of this Dog.
  26.  
  27.    void setColor(char *myColor);
  28. -- Set the Color of this Dog.
  29.  
  30. group: GetMethods;
  31.  
  32.    char *getBreed();
  33. -- Get the breed of this Dog.
  34.  
  35.    char *getColor();
  36. -- Get the color of this Dog.
  37.  
  38. group: AnimalOverrides;
  39.  
  40.    override getGenus;
  41. -- This overrides the animal version.  This returns the genus
  42. -- of a Dog.
  43.  
  44.    override getSpecies;
  45. -- This overrides the animal version.  This returns the species
  46. -- of a Dog.
  47.  
  48.    override display;
  49. -- Displays a Dog.  This method displays the color and breed, and then
  50. -- invokes the parent display to display information about the animal.
  51. -- The parent display will invoke talk() to show what the animal says.
  52. -- The version of talk() defined by Animal uses private Animal data
  53. -- to determine how the animal talks.  But talk() is a method that will
  54. -- be redefined by later derivations of Dog, namely, LittleDog and
  55. -- BigDog.  Both of these classes redefine the talk() method.  So
  56. -- when a LittleDog invokes display(), which will be inherited from
  57. -- this version, the following sequence occurs:
  58. --   1. Dog::display() is invoked.
  59. --   2. Dog::display() invokes Animal::display().
  60. --   3. Animal::display() invokes talk() which has been overridden
  61. --    by LittleDog().
  62. --   4. LittleDog::talk() uses a different algorithm for talking
  63. --    than Animal::talk().
  64.  
  65. group: SystemMethodOverrides;
  66.  
  67.    override somInit;
  68. -- This method will be invoked when a new dog is created.
  69. -- The reason this is automatically invoked is that Dog
  70. -- is derived from Animal, and Animal uses SOMClassInit
  71. -- as its metaclass.
  72.  
  73.    override somUninit;
  74. -- This method is invoked when a Dog object is freed.
  75.  
  76.    override somDumpSelfInt;
  77. -- Invoked when a Dog is dumped.
  78.  
  79.