by James Bott » Wed Dec 05, 2007 3:35 am
Otto,
>I made an ‘invoice class’ and an ‘invoice position (record)’ class.
>Now to calculate the line total I made a function inside the >InvoicePositionclass.
Ok, you picked a very complicated class to start with. An invoice is an object that contains other objects. The invoice object contains a customer object, and multiple line item objects (one for each item). So you need at least three classes to create an Invoice object.
>Amount per price – SetText to a oSay.
>Here I don’t know what to use a function or a method
In pure oop you never use functions. However, in our hybrid OOP system you try not to create functions, but you can use all the FW and Harbour functions. So if you need something new, then create a method.
>METHOD New
>oGet nAmount valid calculate() or ::calculate()
>oGet nPrice valid calculate() or ::calculate()
>oSay nTotal
>return Self
I'm not sure what you were trying to do with the above. The New() method should only initialize the object.
Perhaps you should start with a Customer class instead. It would much simpler than an Invoice class. There is discussion of a customer class in my OOP articles.
James