/////////////////////////////////////////////////
// Copyright 1991, David Brumbaugh
/////////////////////////////////////////////////
#include "paylist.h"
#include <iostream.h>
main()
{
// Test the more abstract Class
Pfm_List db("payroll.db","Employees");
// Create Some Records
db.add();
db.replace("First","John");
db.replace("Last", "Jones");
db.replace("Pay", 11.25);
db.replace("Days",245L);
db.add();
db.replace("First","Ben");
db.replace("Last", "Franklin");
db.replace("Pay", 111.25);
db.replace("Days",3L);
db.add();
db.replace("First","George");
db.replace("Last", "Washington");
db.replace("Pay", 1111.25);
db.replace("Days",4L);
// Then Retreive Them
char first[10], last[20];
long days;
double amount;
db.top();
do
{
cout << db.get("First",first) <<" "<<
db.get("Last",last) <<" "<<
db.get("Pay",amount) <<" ";
db.get("Days",&days);
cout << days << '\n';
db.next();
} while(! db.at_end());
cout << '\n';
amount = 100.00;
if (db.find("Pay",">",&amount))
{
do
{
cout << db.get("First",first) <<" "
<< db.get("Last",last) <<" "
<< db.get("Pay",amount) <<" ";
db.get("Days",&days);
cout << days << '\n';
} while(db.findnext());
}
amount = 11.25;
cout << '\n';
if (db.find(&amount))
{
cout << db.get("First",first) <<" "
<< db.get("Last",last) <<""
<< db.get("Pay",amount) <<" ";
db.get("Days",&days);
cout << days << '\n';
}
// Now Test the application specific class
// Create Some More Records
employee emp[] = {{"Kirk","James",17.01,5},
{"Solo","Han",12.34,4},
{"Hammer","Mike",36.24,36},
{"Hill","Dixon",19.46,30}},
*empPtr, empBuffer;
PayList pl(db. DBHandle());
for(int x=0; x < 3; ++x)
{
pl .add (emp [x] );
}
// Then Retrieve Them Again
pl.top();
do
{
pl.get(empBuffer);
cout << empBuffer.first <<" "<<
empBuffer.last <<" "
<< empBuffer.pay_rate <<" ";
cout << empBuffer.days_worked << '\n';
pl .next();
} while(! pl.at_end());
cout << "\n Done \n";
}
// End of File