| Class TMyObjectClass (unit Objunit) |
TComponent
Its usually a good idea to start from TComponent if methods are involved. True? Why?
| Constructors |
constructor create(Owner: TComponent);| Functions |
function CalcMean(Data: TStringList): double;
destructor Destroy;
procedure MyChange(Senter: TObject);
function GetMean: double;''----------------------------------------------------------------------------} {This function is executed everytime the Mean is retrived.
| Properties |
property Mean : double| Events |
event OnDataChange : TNotifyEvent| Variables |
FMemo : TMemo;
FMean : double;
FNeedToCalc : boolean;
FOnDataChange : TNotifyEvent;| Constructors |
constructor create(Owner: TComponent);''----------------------------------------------------------------------------
| Functions |
function CalcMean(Data: TStringList): double;Making this function public allows access by the application program. See Comments on Calc button.
''----------------------------------------------------------------------------} {Compute the mean of all the strings in a TStringList
destructor Destroy;''----------------------------------------------------------------------------
procedure MyChange(Senter: TObject);''----------------------------------------------------------------------------
function GetMean: double;The current value of the mean
''----------------------------------------------------------------------------} {This function is executed everytime the Mean is retrived. That is, before the Mean is returned, it is recalculated. But only if FNeedToCalc is true.
| Properties |
property Mean : double| Events |
event OnDataChange : TNotifyEvent| Variables |
FMemo : TMemo;Generally, all data should be private and access methods provided. However, in this case if one wanted the user to have complete control over the memo, it might be OK.
FMean : double;The memo contents changed
FNeedToCalc : boolean;
FOnDataChange : TNotifyEvent;True = Mean needs to be recalculated