5 |
The LA Fox Developer Newsletter
|
April 1997
|
The previous diagram illustrates the classes of an employee business object that utilizes polymorphism. Utilizing this format, an entire payroll can be accomplished with very few lines of code as shown in the following example:
Example Employee Business Object using VFP:
SET CLASSLIB TO
‘mynew.vcx’
oEmployee
=
CREATEOBJECT(’employee’
ocompanyState
=
CREATEOBJECT(oEmployee.State) USE employee
SCAN
oEmp
=
CREATEOBJECT(ALLTRIM(employee.title))
=oEmployee.CalcPay(oEmp,oCompanyState)
RELEASE oEmp
ENDSCAN
USE
RELEASE oCompanyState
RELEASE oState
RELEASE oEmpioyee
The main class, Employee, defines the four methods, CalcPay, CalcGross, CalcFed, CalcState.
CalcPay is the main method that calls the other three methods before returning the final payroll figures. It receives as a parameter, an instance of the employee type object, either Hourly, Salary, or Commission and the specific state object for the company.
The CalcGross methods exist in the subclasses of Employee, Hourly, Salary, and Commission where specific methods for calculating GrossPay are located. It is this method that returns the GrossPay back to the Employee.CalcPay method.
The CalcFed is located in the Employee object since all employees calculate federal tax the same way. It returns the FederalTax back to the CalcPay method of the Employee class.
For one client, the code for CalcState could be in the Employee object. This however limits the reusability of the Employee object. Instead, by creating a State class, with the calculations for that state payroll tax as a method, new states can be added by merely creating additional objects. These objects, would then pass the calculated state tax back to the Employee.CalcPay method.
Hot Tip
This tip shows u how to change the mouse cursor to any cursor shape you desire.
declare integer LoadCursorFromFile in win32api as NewCur string declare short SetSystemCursor in win32api Integer ,integer
*
get a handle for a new cursor nCurHndl=NewCur(”c:~vfp\samples\graphics~cursors~down.cur”)
cursor
nchangOK=SetSystemCursor(nCurHndl,3251 2)
*after u changed one of the “system” cursors to ur own
*u can use the MousePointer property to reference it
[Ed. Note: Arnon Gal-Oz is the Head of Computer Dept. of On Time Serial Supply, an Israeli subscription seivices company. He is also the President of the Israeli foxpro User Group, and the Tehcnical Manager of the Virtual Foxpro User Group. If you’re interested in joining this “virtual” group, you may do so by visiting The Visual FoxPro Yellow Pages, at http:I/
www.transformation.com
and filling out the membership application. And best of all? It’s
free!!]
|
As you may know, we’ve added a fifth track to the conference which will be reserved for vendors presenting their products, as well as a Vendor Trade Show. Among vendors participating in the sessions and trade show will be Micromega (Foxfire!), Kevin McNeish (“Framework for Mere Mortals”P’Codebook
for
Mere Mortals”), Roger Woodsmall (AutoManual), Doug Hennig (Stonefield Data Dictionary), Drew Speedie/MaxTech (Visual MaxFrame Professional), and xCase.
|
Business Objects
(Con’t from page 3)
|
Page 5
|
5 |