home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / OOPTUT34.ZIP / JUNIOROB.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-31  |  1KB  |  60 lines

  1. program junior_object;
  2.  
  3. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  4. { Program to illustrate the correct use of Virtual Methods, with unit }
  5. {                                                                     }
  6. { JUNIOROB.PAS  ->  JUNIOROB.EXE      R. Shaw      26.4.91   31.5.93  }
  7. {_____________________________________________________________________}
  8.  
  9. uses Crt, staffobj;
  10.  
  11. type
  12.  
  13. junior = object( staff )
  14.            procedure script1;  virtual;     {virtual procedures which     }
  15.            procedure script2;  virtual;     {override inherited procedures}
  16.            end;
  17.  
  18. procedure junior.script1;
  19. begin
  20.      writeln;
  21.      writeln( '< later >');
  22.      writeln;
  23.      writeln( Name, ': I do not know the letter to send for an overdraft.');
  24.      writeln;
  25. end;
  26.  
  27. procedure junior.script2;
  28. begin
  29.      writeln( Name, ': Thank you. ');
  30.      writeln;
  31.      writeln( '< later still >' );
  32.      writeln;
  33.      writeln( Name, ': As you requested, I sent the letter headed ',LetterName,'.');
  34. end;
  35.  
  36. {Main}
  37.  
  38. var
  39.    Young      : junior;
  40.    Old        : staff;
  41.  
  42. begin
  43.      clrscr;
  44.  
  45.      Young.Init( 'NEWMAN' );
  46.      Old.Init( 'SENIOR' );
  47.  
  48.      Old.action1;
  49.      Young.action1;
  50.      Old.action2;
  51.      Young.action2;
  52.  
  53.      gotoXY(10,24);
  54.      write('Press any key to conclude: ');
  55.      repeat until keypressed;
  56.      clrscr;
  57. end.
  58.  
  59. { end of listing }
  60.