Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class platnosc {
- private:
- char * nazwa;
- double kwota;
- int dzien;
- int miesiac;
- int rok;
- public:
- platnosc(char * nazwa, double kwota, int dzien, int miesiac, int rok) : nazwa(nazwa), kwota(kwota), dzien(dzien), miesiac(miesiac), rok(rok){}
- ~platnosc(){
- delete[] nazwa;
- }
- bool operator< (const platnosc & plat) const{
- if (rok < plat.rok) return true;
- if (rok > plat.rok) return false;
- if (miesiac < plat.miesiac) return true;
- if (miesiac > plat.miesiac) return false;
- if (dzien < plat.dzien) return true;
- if (dzien > plat.dzien) return false;
- return false;
- }
- };
- class stos_platnosci {
- protected:
- platnosc ** tab;
- int rozmiar;
- int pozycja;
- public:
- stos_platnosci(int rozmiar){
- this->rozmiar = rozmiar;
- this->pozycja = -1;
- this->tab = new platnosc*[rozmiar];
- }
- platnosc * operator-=(int temp){
- if (this->pozycja == -1) return nullptr;
- platnosc * plat = this->tab[this->pozycja];
- delete this->tab[this->pozycja];
- this->pozycja--;
- return plat;
- }
- virtual bool put(platnosc * plat){
- if ((this->rozmiar - this->pozycja) == 1) return false;
- this->pozycja++;
- this->tab[this->pozycja] = plat;
- return true;
- }
- int pobierzPozycje(){
- return this->pozycja;
- }
- platnosc ** pobierzTablice(){
- return this->tab;
- }
- int pobierzRozmiar(){
- return this->rozmiar;
- }
- };
- class kolejka_wydatkow : public stos_platnosci {
- private:
- void czysc(){
- if (this->pozycja > -1)
- for (int i = 0; i <= this->pozycja; i++)
- delete this->tab[i];
- this->pozycja = -1;
- delete[] this->tab;
- }
- public:
- ~kolejka_wydatkow(){
- this->czysc();
- }
- bool put(platnosc * plat){
- if ((this->rozmiar - this->pozycja) == 1) return false;
- this->pozycja++;
- if (this->pozycja == 0){
- this->tab[this->pozycja] = plat;
- return true;
- }
- for (int i = this->pozycja - 1; i > 0; i--){
- if (this->tab[i] < plat){
- this->tab[i + 1] = this->tab[i];
- }else{
- this->tab[i + 1] = plat;
- return true;
- }
- }
- this->tab[0] = plat;
- return true;
- }
- bool operator=(stos_platnosci &stos){
- if (stos.pobierzPozycje() == -1) return false;
- this->czysc();
- this->tab = new platnosc*[stos.pobierzRozmiar()];
- this->rozmiar = stos.pobierzRozmiar();
- platnosc ** tablica = stos.pobierzTablice();
- for (int i = 0; i <= stos.pobierzPozycje(); i++)
- this->put(tablica[i]);
- return true;
- }
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement