Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct Piosenki {
- string tytul, autor, gatunek;
- float czas;
- int ocena;
- void sprawdz() {
- if (ocena < 1 || ocena > 5) {
- ocena = 1;
- }
- }
- void pokaz() {
- cout << "Tytul: " << tytul << " - " << "Autor: " << autor << " - " << "Gatunek: " << gatunek << " - " << "Czas: " << czas << " - " << "Ocena: " << ocena << endl << endl;
- }
- };
- class Klient {
- private:
- string imie, nazwisko;
- int indeks;
- public:
- int id;
- const int plimit = 3;
- int licz_piosenke;
- Klient() {};
- Klient(int idx, string a, string b) {
- imie = a;
- nazwisko = b;
- indeks = idx;
- }
- Klient & operator =(Klient &klient) {
- Klient kl;
- kl.set_indeks(klient.get_indeks());
- kl.set_nazwisko(klient.get_nazwisko());
- kl.set_imie(klient.get_imie());
- return kl;
- }
- Piosenki* piosenka = new Piosenki[plimit];
- string get_imie() {
- return imie;
- }
- string get_nazwisko() {
- return nazwisko;
- }
- int get_indeks() {
- return indeks;
- }
- void set_imie(string i) {
- imie = i;
- }
- void set_nazwisko(string n) {
- nazwisko = n;
- }
- void set_indeks(int in) {
- indeks = in;
- }
- void name() {
- cout << "Imie: " << imie << " | Nazwisko: " << nazwisko << " | Indeks: " << indeks << " - Ilosc dodanych piosenek wynosi = " << licz_piosenke << endl << endl;
- }
- void dodaj_piosenke();
- void pokaz_piosenke();
- };
- class Klienci : public Klient{
- friend class Klient;
- public:
- const int Limit = 1;
- int licz_klienta = 0;
- int indeks_klienta = 0;
- Klient *klci = new Klient[Limit];
- int liczba_klientow() {
- cout << "Ilosc dodanych klientow wynosi = ";
- return licz_klienta;
- cout << endl;
- }
- int liczba_piosenek() {
- cout << "Ilosc dodanych piosenek wynosi = ";
- return licz_piosenke;
- }
- void dodaj_klienta(const Klient &);
- //void sortuj_ponazwisku();
- Klienci() {};
- };
- /*
- void Klienci::sortuj_ponazwisku() {
- cout << "Sortowanie" << endl;
- for (int i = 0; i < licz_klienta; i++) {
- tab->name();
- *tab++;
- }
- }
- */
- void Klienci::dodaj_klienta(Klient * klient) {
- klci[indeks_klienta] = klient;
- indeks_klienta++;
- }
- void Klient::dodaj_piosenke() {
- string check = "";
- cout << "DODAJ PIOSENKE " << endl;
- for (int i = 0; i < plimit; i++) {
- cout << "Podaj tytul: ";
- cin >> piosenka[i].tytul;
- cout << "Podaj autora: ";
- cin >> piosenka[i].autor;
- cout << "Podaj gatunek: ";
- cin >> piosenka[i].gatunek;
- cout << "Podaj czas trwania: ";
- cin >> piosenka[i].czas;
- cout << "Podaj ocene: ";
- cin >> piosenka[i].ocena;
- cout << endl;
- piosenka[i].sprawdz();
- if (i < plimit-1) {
- cout << "CZY CHCESZ DODAC PIOSENKE? Wpisz 'tak' lub 'nie'." << endl;
- cin >> check;
- }
- licz_piosenke++;
- if (check == "nie") {
- break;
- }
- }
- }
- void Klient::pokaz_piosenke() {
- for (int i = 0; i < licz_piosenke; i++) {
- cout << "Piosenka " << i+1 << " | ";
- piosenka[i].pokaz();
- }
- }
- int main() {
- Klienci nowi;
- string q, w;
- cout << "DODAJ KLIENTA" << endl;
- for (int i = 0; i < nowi.Limit; i++) {
- cout << "Podaj imie: ";
- cin >> q;
- cout << "Podaj nazwisko: ";
- cin >> w;
- cout << endl;
- Klient kl(nowi.indeks_klienta, q, w);
- nowi.dodaj_klienta(kl);
- }
- cout << nowi.liczba_klientow() << endl;
- cout << nowi.liczba_piosenek() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement