// Include #include #include #include #include #include #include using namespace std; // Definicion de Clases class c_fecha { public: c_fecha(); //Construye con fecha actual c_fecha(int x, int y, int z):dia(x),mes(y),ano(z){}; //Copia argumento friend ostream & operator << (ostream & os, const c_fecha & fe); friend istream & operator >> (istream & os, c_fecha & fe); friend bool operator < (c_fecha & f1, c_fecha & f2); //Lanza stream ej: 10 Diciembre 2000 void c_fecha::display() const; //Despliega por pantalla void c_fecha::input(); //Ingresa Valor private: int dia; int mes; int ano; }; class cheque { public: cheque(); cheque(int x, double y, c_fecha z, c_fecha w, string & u, string & d); //Construye con argumentos void cheque::input(); //Ingresa void cheque::display(string []) const; //Despliega por pantalla c_fecha cheque::fcobro(); //Devuelve fecha de cobro double cheque::fmonto(); //Devuelve monto de cobro friend ostream & operator << (ostream & os, const cheque & temp); friend istream & operator >> (istream & os, cheque & temp); friend bool operator < (cheque & c1, cheque & c2); private: int id_banco; double monto; c_fecha cobro; c_fecha emite; string destino; string desc; }; class cuenta { public: cuenta(); private: }; class usuarios { public: private: }; // Implementacion de Clases //*** Clase Fecha *** c_fecha::c_fecha() //Constructor { time_t t1; struct tm *t2; t1=time(NULL); t2=localtime(&t1); dia=t2->tm_mday; mes=t2->tm_mon+1; ano=t2->tm_year+1900; } bool operator < (c_fecha & f1, c_fecha & f2) { if (f1.ano>f2.ano) return 0; if (f1.anof2.mes) return 0; if (f1.mesf2.dia) return 0; if (f1.dia> (istream & os, c_fecha & fe) { os>>fe.dia>>fe.mes>>fe.ano; return os; } istream & operator >> (istream & os, cheque & temp) { os>>temp.id_banco>>temp.monto; os>>temp.cobro>>temp.emite; os>>temp.destino>>temp.desc; return os; } ostream & operator << (ostream & os, const cheque & temp) { os<>dia; cout<<" [Mes] : "; cin>>mes; cout<<" [Año] : "; cin>>ano; } //*** Clase Cheque *** cheque::cheque() { id_banco=0; monto=0; } c_fecha cheque::fcobro() { c_fecha tmp; tmp=cobro; return tmp; } double cheque::fmonto() { double tmp; tmp=monto; return tmp; } cheque::cheque(int x, double y, c_fecha z, c_fecha w, string &u, string &d) { id_banco=x; monto=y; cobro=z; emite=w; destino=u; desc=d; } void cheque::input() { string d; string dc; cout<<"Ingrese ID del Banco : "; cin>>id_banco; cout<<"Ingrese Monto del Cheque : "; cin>>monto; cout<<"Ingrese Fecha de Emision : "; emite.input(); cout<<"Ingrese Fecha de Cobro : "; cobro.input(); cout<<"Ingrese Destinatario : "; cin>>destino; cout<<"Ingrese Descripcion : "; cin>>desc; } void cheque::display(string index[]) const { cout<<"\n**************************************************\n"; cout<<"Banco : "< & l_cheques,string index[],int n_ids); void showbank(string index[],int n_ids); void show_lista(list & l_cheques, string index[]); void save_lista(list & l_cheques); void erase_cheque(list & l_cheques, string index[]); void calculo(list l_cheques, string index[], int n_ids); // Programa Principal int main(void) { int n_ids=0; //Bancos existentes char b_name[256]; int b_id=0; int op; int menu1; ifstream ids; string index[20]; //Donde se almacenan los bancos //Carga de Bancos en Lista cout<<"\n** Iniciando Programa\n"; cout<<"\n** Cargando lista de Bancos..."; ids.open("databanc.dat"); while(ids) { ids>>b_name; if (strcmp(b_name,"\0")) { index[n_ids]=b_name; n_ids++; } } ids.close(); cout<<"\n** Se han encontrado "< l_cheques; list ::iterator it_c; //Carga de Cheques cout<<"\n** Cargando lista de cheques ingresados"; ids.open("seba.dat"); cheque cnew; while(ids) { ids>>cnew; l_cheques.push_back(cnew); } ids.close(); l_cheques.pop_back(); l_cheques.sort(); cout<<"\n** Se han encontrado "< Opcion ? "; cin>>op; switch (op) { case 1: add_cheque(l_cheques, index, n_ids); break; case 2: erase_cheque(l_cheques, index) ; break; case 3: calculo(l_cheques, index, n_ids); break; case 4: show_lista(l_cheques, index); break; case 5: save_lista(l_cheques); break; case 6: save_lista(l_cheques); menu1=0; break; } } return 0; } void calculo(list l_cheques, string index[], int n_ids) { list ::iterator it; c_fecha futura,hoy,tempo; int cc=0; double necesario=0; cout<<"\n** Fecha de Hoy: "; hoy.display(); cout<<"\n** Para calcular saldo ingrese fecha futura\n"; futura.input(); for(it=l_cheques.begin(); it!=l_cheques.end(); it++) { tempo=(*it).fcobro(); if (tempo & l_cheques, string index[]) { char op; list::iterator it; cout<<"\n** Existen "<>op; if ((op=='s')||(op=='S')) { l_cheques.erase(it); it--; } } l_cheques.sort(); } void show_lista(list & l_cheques, string index[]) { cout<<"\n** Existen "<::iterator it; for(it=l_cheques.begin(); it!=l_cheques.end(); it++) { (*it).display(index); } } void save_lista(list & l_cheques) { ofstream user; l_cheques.sort(); list ::iterator it_c; user.open("seba.dat"); for(it_c=l_cheques.begin();it_c!=l_cheques.end();it_c++) { user<<(*it_c); } user.close(); cout<<"\n** Lista Guardada\n"; } //Agrega cheque a lista //Parametros: lista donde se agrega, indice de bancos void add_cheque(list & l_cheques,string index[],int n_ids) { cout<<"\n** Bancos Disponibles\n\n"; showbank(index,n_ids); cout< "<