Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- using namespace std;
- class monitor
- {
- int diagonala,pret;
- friend class LED;
- friend class LCD;
- friend void stergere_LED();
- public:
- string producator;
- monitor(string producator, int diagonala, int pret)
- {
- this->diagonala = diagonala;
- this->producator = producator;
- this->pret = pret;
- }
- void afisare_monitor()
- {
- cout << "Producator: ";
- cout << producator << endl;
- cout << "Diagonala:";
- cout << diagonala << endl;
- cout << "Pret:";
- cout << pret << endl;
- }
- /*void adaugare_monitor()
- {
- cout << "Producator: ";
- cin >> producator;
- cout << "Diagonala: ";
- cin >> diagonala;
- cout << "Pret: ";
- cin >> pret;
- }*/
- };
- class LED :public monitor
- {
- int timp_raspuns;
- LED* next;
- LED* head;
- public:
- LED(string producator, int diagonala, int pret, int timp_raspuns) :monitor(producator, diagonala, pret)
- {
- this->timp_raspuns = timp_raspuns;
- head = NULL;
- }
- void afisare_LED()
- {
- LED* p = head;
- while (p != NULL)
- {
- cout << "Producator: ";
- cout << p->producator << endl;
- cout << "Diagonala:";
- cout << p->diagonala << endl;
- cout << "Pret:";
- cout << p->pret << endl;
- cout << "Timp raspuns: ";
- cout << p->timp_raspuns << endl << endl;
- p = p->next;
- }
- }
- void adaugare_LED()
- {
- cout << "Producator: ";
- cin >> producator;
- cout << "Diagonala: ";
- cin >> diagonala;
- cout << "Pret: ";
- cin >> pret;
- cout << "Timp raspuns: ";
- cin >> timp_raspuns;
- LED* p = new LED(producator, diagonala, pret, timp_raspuns);
- p->next = head;
- head = p;
- }
- void stergere_LED()
- {
- char prod[20];
- cout << "Dati producatorul LED-ului pentru stergere: ";
- cin >> prod;
- cout << endl;
- LED* comp = head;
- LED* del;
- if (strcmp(comp->producator.c_str(), prod) == 0)
- {
- del = comp;
- head = comp->next;
- delete del;
- }
- else
- {
- while (strcmp(comp->next->producator.c_str(), prod) != 0 && comp->next)
- {
- comp = comp->next;
- }
- del = comp->next;
- comp->next = comp->next->next;
- //c->urm = del->urm;
- delete del;
- }
- afisare_LED();
- }
- void cautare_LED()
- {
- string prod;
- cout << "Dati producatorul LED-ului pentru cautare: ";
- cin >> prod;
- LED* comp = head;
- while (comp)
- {
- if (strcmp(comp->producator.c_str(), prod.c_str()) == 0)
- {
- cout << endl;
- afisare_LED();
- break;
- }
- }
- }
- };
- class LCD :public monitor
- {
- int boxe,format;
- LCD* head;
- LCD* next;
- public:
- LCD(string producator, int diagonala, int pret,int format,int boxe) :monitor(producator, diagonala, pret)
- {
- this->format = format;
- this->boxe = boxe;
- head = NULL;
- }
- void afisare_LCD()
- {
- LCD* p=head;
- while (p != NULL)
- {
- cout << "Producator: ";
- cout <<p->producator << endl;
- cout << "Diagonala:";
- cout <<p->diagonala << endl;
- cout << "Pret:";
- cout <<p->pret << endl;
- cout << "Format: ";
- cout <<p->format << endl;
- cout << "Boxe: ";
- cout << p->boxe << endl << endl;
- p = p->next;
- }
- }
- void adaugare_LCD()
- {
- cout << "Producator: ";
- cin >> producator;
- cout << "Diagonala: ";
- cin >> diagonala;
- cout << "Pret: ";
- cin >> pret;
- cout << "Format: ";
- cin >> format;
- cout << "Boxe: ";
- cin >> boxe;
- LCD* p = new LCD(producator, diagonala, pret, format,boxe);
- p->next = head;
- head = p;
- }
- void stergere_LCD()
- {
- char prod[20];
- cout << "Dati producatorul LCD-ului pentru stergere: ";
- cin >> prod;
- cout << endl;
- LCD* comp = head;
- LCD* del;
- if (strcmp(comp->producator.c_str(), prod) == 0)
- {
- del = comp;
- head = comp->next;
- delete del;
- }
- else
- {
- while (strcmp(comp->producator.c_str(), prod) != 0 && comp->next)
- {
- comp = comp->next;
- }
- del = comp->next;
- comp->next = comp->next->next;
- //c->urm = del->urm;
- delete del;
- }
- afisare_LCD();
- }
- void cautare_LCD()
- {
- string prod;
- cout << "Dati producatorul LCD-ului pentru cautare: ";
- cin >> prod;
- LCD* comp = head;
- while (comp)
- {
- if (strcmp(comp->producator.c_str(), prod.c_str()) == 0)
- {
- cout << endl;
- afisare_LCD();
- break;
- }
- }
- }
- };
- int main()
- {
- LED* a = new LED(" ", 0, 0, 0);
- LCD* b=new LCD(" ",0,0,0,0);
- string producator;
- int diagonala, pret, boxe, timp_raspuns,n,n2,format;
- enum{iesire, citire, afisare, stergere, cautare, ordonare}opt;
- do {
- cout << "0. Iesire" << endl;
- cout << "1. Citire" << endl;
- cout << "2. Afisare" << endl;
- cout << "3. Stergere" << endl;
- cout << "4. Cautare" << endl;
- cout << "5. Ordonare" << endl;
- cout << "opt= ";
- cin >> n;
- switch (n)
- {
- case iesire:exit(0);
- break;
- case citire:cout <<endl<< "1.Led" << endl;
- cout << "2.Lcd" << endl;;
- cout << "opt= ";
- cin >> n2;
- if (n2 == 1)
- {
- a->adaugare_LED();
- }
- else
- {
- b->adaugare_LCD();
- }
- cout << endl;
- break;
- case afisare:
- cout << endl<<"1.Led" << endl;
- cout << "2.Lcd" << endl;;
- cout << "opt= ";
- cin >> n2;
- cout << endl;
- if (n2 == 1)
- {
- a->afisare_LED();
- }
- else
- {
- b->afisare_LCD();
- }
- cout << endl;
- break;
- case stergere:
- cout << endl << "1.Led" << endl;
- cout << "2.Lcd" << endl;;
- cout << "opt= ";
- cin >> n2;
- if (n2 == 1)
- {
- a->stergere_LED();
- }
- else
- {
- b->stergere_LCD();
- }
- cout << endl;
- break;
- case cautare:
- cout << endl << "1.Led" << endl;
- cout << "2.Lcd" << endl;;
- cout << "opt= ";
- cin >> n2;
- if (n2 == 1)
- {
- a->cautare_LED();
- }
- else
- {
- b->cautare_LCD();
- }
- break;
- case ordonare:
- break;
- default:
- break;
- }
- } while (1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement