Advertisement
Guest User

Untitled

a guest
May 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. type
  2. IMoney = interface
  3. function Value: Currency;
  4. end;
  5.  
  6. TPercentCalculated = class(TInterfacedObject, IMoney)
  7. public
  8. constructor Create(
  9. OriginalValue, Percent: Currency);
  10. class function New(
  11. OriginalValue, Percent: Currency): IMoney;
  12. function Value: Currency;
  13. end;
  14.  
  15. implementation
  16.  
  17. constructor TPercentCalculated.Create(
  18. OriginalValue, Percent: Currency);
  19. begin
  20. FOriginalValue := OriginalValue;
  21. FPercent := Percent;
  22. end;
  23.  
  24. class function TPercentCalculated.New(
  25. OriginalValue, Percent: Currency): IMoney;
  26. begin
  27. Result := Create(OriginalValue, Percent);
  28. end;
  29.  
  30. function TPercentCalculated.Value: Currency;
  31. begin
  32. if FPercent > 0 then
  33. Result := (FOriginalValue * Percent) / 100
  34. else
  35. Result := FOriginalValue;
  36. end;
  37.  
  38. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement