Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Mateusz Przybyla
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <map>
- using namespace std;
- class Zadanie
- {
- public:
- const int id;
- static int ileUtworzono;
- static int ileObiektow;
- static map < const int, Zadanie* > lista;
- void ( * akcja ) ( const Zadanie & );
- Zadanie ( void funkcja ( const Zadanie &z ) = 0 ) : id ( ++ileUtworzono )
- {
- ileObiektow++;
- akcja = funkcja;
- lista [ id ] = this;
- }
- Zadanie ( const Zadanie & z ) : id ( ++ileUtworzono )
- {
- ileObiektow++;
- akcja = z.akcja;
- lista [ id ] = this;
- }
- ~Zadanie ()
- {
- ileObiektow--;
- map < const int, Zadanie * > :: iterator i;
- for ( i = lista.begin(); i != lista.end(); i++ )
- {
- if ( ( *i ).second == this )
- {
- lista.erase ( i );
- break;
- }
- }
- }
- void wykonaj ()
- {
- if ( akcja == 0 )
- cout << "BRAK AKCJI" << endl;
- else
- akcja ( *this );
- }
- static void wykonaj ( const int numer )
- {
- bool czyJest = false;
- map < const int, Zadanie * > :: iterator i;
- for ( i = lista.begin(); i != lista.end(); i++ )
- if ( ( *i ).first == numer )
- {
- ( *i ).second->wykonaj();
- czyJest = true;
- }
- if ( !czyJest )
- cout << "BRAK ZADANIA" << endl;
- }
- void zmien ( void funkcja ( const Zadanie & z ) = 0 )
- {
- akcja = funkcja;
- }
- static void raport ()
- {
- cout << "[ " << ileUtworzono << " | " << ileObiektow << " | ";
- map < const int, Zadanie * > :: iterator i;
- for ( i = lista.begin(); i != lista.end(); i++ )
- cout << ( *i ).first << " ";
- cout << "]" << endl;
- }
- };
- int Zadanie :: ileObiektow = 0;
- int Zadanie :: ileUtworzono = 0;
- map < const int, Zadanie* > Zadanie :: lista;
Add Comment
Please, Sign In to add comment