home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue62 / ClassEng / Listing3.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-09-01  |  607 b   |  30 lines

  1. Listing 3
  2.  
  3.   TParent = class(TObject)
  4.   public
  5.     function ReturnOnInvestment: Double;
  6.   end;
  7.   TChild = class(TParent)
  8.   public
  9.     function ReturnOnInvestment: Double;
  10.   end;
  11.   ...
  12.  
  13. { TParent }
  14. function TParent.ReturnOnInvestment: Double;
  15. begin
  16.   Result := <some calculation>;
  17. end;
  18.  
  19. { TChild }
  20. function TChild.ReturnOnInvestment: Double;
  21. begin
  22.   // get ROI from parent method;  if news is good, make it
  23.   // better;  if news is bad, make it less so
  24.   Result := inherited ReturnOnInvestment;
  25.   if Result > 0 then
  26.     Result := Result * 2
  27.   else
  28.     Result := Result / 2;
  29. end;
  30.