Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Monitor {
- private:
- string *producator;
- double diagonala, pret;
- public:
- Monitor(string &producator, double diagonala, double pret) {
- this->producator = new string;
- *this->producator = producator;
- this->diagonala = diagonala;
- this->pret = pret;
- }
- ~Monitor() { delete producator; }
- string ReturnProducator() { return *producator; }
- void Show() {
- cout << "\nDetalii despre Monitor:";
- cout << "\nProducator: " << *producator;
- cout << "\nDiagonala: " << diagonala << " cm";
- cout << "\nPret: " << pret << " lei";
- }
- };
- class LCD : public Monitor {
- private:
- string *tipEcran, *conectori;
- double timpRaspuns;
- LCD *next;
- static LCD *headLCD;
- public:
- LCD(string &, double, double, double, string &, string &);
- ~LCD() { delete tipEcran, conectori;}
- static void ShowLCD();
- void Show() {
- Monitor::Show();
- cout << "\nTimp de raspuns: " << timpRaspuns << " s";
- cout << "\nTip ecran: " << *tipEcran;
- cout << "\nConectori: " << *conectori << endl;
- }
- };
- LCD *LCD::headLCD = NULL;
- LCD::LCD(string &producator, double diagonala, double timpRaspuns, double pret, string &tipEcran, string &conectori) : Monitor(producator, diagonala, pret) {
- this->tipEcran = new string;
- *this->tipEcran = tipEcran;
- this->conectori = new string;
- *this->conectori = conectori;
- this->timpRaspuns = timpRaspuns;
- next = NULL;
- if (headLCD == NULL) {
- headLCD = this;
- return;
- }
- if (headLCD->ReturnProducator() > this->ReturnProducator()) {
- this->next = headLCD;
- headLCD = this;
- return;
- }
- LCD *q = headLCD;
- while (q->next != NULL && q->next->ReturnProducator() < this->ReturnProducator()) q = q->next;
- this->next = q->next;
- q->next = this;
- }
- void LCD::ShowLCD() {
- LCD * q = headLCD;
- while (q)
- {
- q->Show();
- q = q->next;
- }
- }
- int main() {
- string producator, tipEcran, conectori;
- double pret, diagonala, timpRaspuns;
- unsigned opt;
- int isLCD;
- do {
- cout << "\n1. Adaugare monitor LCD/LED";
- cout << "\n2. Afisare monitoare LCD/LED";
- cout << "\n6. Iesire.";
- cout << "\nOptiunea dorita: "; cin >> opt;
- system("cls");
- switch (opt)
- {
- case 1:
- cout << "\nTip monitor (1-LCD/ 0-LED): "; cin >> isLCD;
- cout << "\nProducator: "; cin >> producator;
- cout << "Diagonala: "; cin >> diagonala;
- cout << "Pret: "; cin >> pret;
- if (isLCD) {
- cout << "Timp de raspuns: "; cin >> timpRaspuns;
- cout << "Tip ecran: "; cin >> tipEcran;
- cout << "Conectori: "; cin >> conectori;
- new LCD(producator, diagonala,timpRaspuns, pret, tipEcran, conectori);
- }
- break;
- case 2:
- cout << "\nTip monitor (1-LCD/ 0-LED): "; cin >> isLCD;
- if (isLCD) LCD::ShowLCD();
- default:
- break;
- }
- } while (true);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment