//Schedario.cpp #include #include "schedario.h" using namespace std; Schedario::Schedario( ) { } void Schedario::nuovaScheda( string t, string m, int a ) { Scheda s(t,m,a); elenco[t] = s; //ATTENZIONE: crea una coppia (t, Scheda()) //in elenco e copia i valori di s //E' necessario definire Scheda::Scheda() //Se elenco[t] esiste gia', //i dati sono sovrascritti } Scheda * Schedario::cerca( string t ) { map::iterator i; i=elenco.find(t); if ( i==elenco.end() ) return NULL; else return &( i->second); } void Schedario::eliminaScheda( string t ) { elenco.erase(t); } int Schedario::numeroSchede() { return elenco.size(); } void Schedario::print() { int k=1; cout << "\n|------------------------------------------------------------|"; cout << "\n| AUTO PRESENTI NELLO SCHEDARIO: "; cout << "\n|------------------------------------------------------------|\n"; map::iterator i; for (i=elenco.begin(); i!=elenco.end(); ++i, ++k) { cout << "| Auto " << k << ": " << i->second << endl; } cout << "|------------------------------------------------------------|\n\n"; }