/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* CHECK.CPP Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Contains definition of Check class members and functions. */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 05-09-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "check.h" #include #include #include #include #include /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Add() Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Adds this to the Check list. Sets up pointers, */ /* defualt values, and figures current balance. */ /* */ /* Input: Number */ /* Desc */ /* Check */ /* Deposit */ /* Prev */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 05-25-91 ACP initial creation */ /* 06-08-91 ACP converted from constructor to member function */ /* 07-20-91 ACP automatic date set /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::Add(int Number, char *Desc, float Check, float Deposit, Check *Prev) { number = Number; getdate(&date); strcpy(desc, Desc); check = Check; deposit = Deposit; cleared = 0; prev = Prev; if (prev != NULL) { next = prev->Next(); prev->NewNext(this); balance = prev->Balance() + deposit - check; } else { next = NULL; balance = deposit - check; } } /* end of function Add() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Edit() Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Updates the information in this Check with the given */ /* parameters. Fix() should be called for the Check list after this */ /* function executes. */ /* */ /* Input: Number */ /* Date */ /* Desc */ /* Check */ /* Deposit */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 05-25-91 ACP initial creation */ /* 07-24-91 ACP implement date as a structure */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::Edit(int Number, _Date *Date, char *Desc, float Check, float Deposit) { number = Number; date.da_mon = Date->da_mon; date.da_day = Date->da_day; date.da_year = Date->da_year; strcpy(desc, Desc); check = Check; deposit = Deposit; balance = prev->Balance() + deposit - check; } /* end of function Edit() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Read() Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Reads all necessary information for this check from the */ /* given input stream. */ /* */ /* Input: fp opened input stream */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 06-23-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::Read(istream& fp, Check *Prev) { record = 0; //default - not yet implemented *this << fp; prev = Prev; if (prev != NULL) { next = prev->Next(); prev->NewNext(this); balance = prev->Balance() + deposit - check; } else { next = NULL; balance = deposit - check; } } /* end of function Read() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Remove() Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Updates the pointers for this and the surrounding checks */ /* in order to remove this object from the list. This should be done */ /* prior to deleting an instance of a CHECK. */ /* */ /* Input: none */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 06-08-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::Remove() { if (prev != NULL) prev->NewNext(next); if (next != NULL) next->NewPrev(prev); prev = NULL; next = NULL; } /* end of function Remove() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* WhoCheck() Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Returns all the pertinent information for this check */ /* in a XACT structure. */ /* */ /* Input: XACT structure */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 05-25-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::WhoCheck(XACT *xact) { xact->number = number; xact->date = date; strcpy(xact->desc, desc); xact->check = check; xact->deposit = deposit; xact->balance = balance; xact->cleared = cleared; } /* end of function WhoCheck() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Write() Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Writes all necessary information for this check into the */ /* given output stream. */ /* */ /* Input: fp opened output stream */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 06-09-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::Write(ostream& fp) { *this >> fp; } /* end of function Write() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* operator >> Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Writes all necessary information for this check into the */ /* given output stream. */ /* */ /* Input: fp opened output stream */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 06-26-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::operator>> (ostream& fp) { fp << number << ","; fp << (int)date.da_mon << ","; fp << (int)date.da_day << ","; fp << date.da_year << ","; fp << check << ","; fp << deposit << ","; fp << (int)cleared << ","; fp << desc << '\n'; } /* end of operator >> function */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* operator << Alan C. Partis */ /* Copyright (C) AP MicroSystems, 1991 */ /* */ /* Description: Reads all necessary information for this check from the */ /* given input stream. */ /* */ /* Input: fp opened input stream */ /* */ /* Output: none */ /* */ /* Date Initials Comments */ /* ----------------------------------------------------------------------- */ /* 06-26-91 ACP initial creation */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Check::operator<< (istream& fp) { char instr[SZ_MAX_FIELD]; fp.getline(instr, SZ_MAX_FIELD, ','); number = atoi(instr); fp.getline(instr, SZ_MAX_FIELD, ','); date.da_mon = atoi(instr); fp.getline(instr, SZ_MAX_FIELD, ','); date.da_day = atoi(instr); fp.getline(instr, SZ_MAX_FIELD, ','); date.da_year = atoi(instr); fp.getline(instr, SZ_MAX_FIELD, ','); check = atof(instr); fp.getline(instr, SZ_MAX_FIELD, ','); deposit = atof(instr); fp.getline(instr, SZ_MAX_FIELD, ','); cleared = atoi(instr); fp.getline(desc, SZ_DESC); filter(desc, EOL); } /* end of operator << function */
Copyright © Thundernet Development Group Inc., 2003. All rights reserved. |