Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- IMoney = interface
- function Value: Currency;
- end;
- TPercentCalculated = class(TInterfacedObject, IMoney)
- public
- constructor Create(
- OriginalValue, Percent: Currency);
- class function New(
- OriginalValue, Percent: Currency): IMoney;
- function Value: Currency;
- end;
- implementation
- constructor TPercentCalculated.Create(
- OriginalValue, Percent: Currency);
- begin
- FOriginalValue := OriginalValue;
- FPercent := Percent;
- end;
- class function TPercentCalculated.New(
- OriginalValue, Percent: Currency): IMoney;
- begin
- Result := Create(OriginalValue, Percent);
- end;
- function TPercentCalculated.Value: Currency;
- begin
- if FPercent > 0 then
- Result := (FOriginalValue * Percent) / 100
- else
- Result := FOriginalValue;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement