Last active
May 3, 2026 10:12
-
-
Save thinkphp/ae7d39dd00b4c0d7b76ce090c06e27df to your computer and use it in GitHub Desktop.
Carte de vizita Proiect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <cstring> | |
| using namespace std; | |
| // =============================================== | |
| // clasa de baza: carte de vizita | |
| //================================================ | |
| class CarteDeVizita { | |
| protected: | |
| //campuri | |
| char *nume; //alocat dinamic | |
| string telefon; | |
| string email; | |
| string companie; | |
| //campuri specifice | |
| string tipMaterial; //carton, platic, metal | |
| int nrExemplare; | |
| double latime; | |
| double inaltime; | |
| string categorie; //personal, business | |
| double cost; | |
| //membru static: contor total carti de vizita create | |
| static int totalCarti; | |
| public: | |
| // | |
| // Constructori | |
| // | |
| //constructor implicit | |
| CarteDeVizita(): telefon(""),email(""),companie(""), tipMaterial("carton"),nrExemplare(1),latime(9.0), inaltime(1.0),categorie("business"), cost(0.0) | |
| { | |
| nume = new char[1]; | |
| nume[0] = '\0'; | |
| totalCarti++; | |
| } | |
| //constructor cu parametri | |
| CarteDeVizita(const char* _nume, const string& _telefon, | |
| const string& _email, const string& _companie, | |
| const string& _tipMaterial, int _nrExemplare, | |
| double _latime, double _inaltime, | |
| const string _categorie, double _cost): | |
| telefon(_telefon), email(_email), companie(_companie), | |
| tipMaterial(_tipMaterial), nrExemplare(_nrExemplare), | |
| latime(_latime), inaltime(_inaltime), | |
| categorie(_categorie), cost(_cost) | |
| { | |
| nume = new char[strlen(_nume) + 1]; | |
| strcpy(nume, _nume); | |
| totalCarti++; | |
| } | |
| //destructorul clasei | |
| virtual ~CarteDeVizita() { | |
| delete[] nume; | |
| totalCarti--; | |
| } | |
| //operator de atribuire | |
| CarteDeVizita& operator=(const CarteDeVizita& other) { | |
| if(this != &other) { | |
| delete [] nume; | |
| nume = new char[strlen(other.nume) + 1]; | |
| strcpy(nume, other.nume); | |
| telefon = other.telefon; | |
| email = other.email; | |
| companie = other.companie; | |
| tipMaterial = other.tipMaterial; | |
| nrExemplare = other.nrExemplare; | |
| latime = other.latime; | |
| inaltime = other.inaltime; | |
| categorie = other.categorie; | |
| cost = other.cost; | |
| } | |
| return *this; | |
| } | |
| // | |
| // Getteri si Setteri | |
| // | |
| const char* getNume() const {return nume;} | |
| string getTelefon() const {return telefon;} | |
| string getEmail() const {return email;} | |
| string getCompanie() const {return companie;} | |
| string getTipMaterial() const {return tipMaterial;} | |
| int getNrExemplare() const {return nrExemplare;} | |
| double getLatime() const {return latime;} | |
| double getInaltime() const {return inaltime;} | |
| string getCategorie() const {return categorie;} | |
| double getCost() const {return cost;} | |
| void setNume(const char* _nume) { | |
| delete[] nume; | |
| nume = new char[strlen(_nume) + 1]; | |
| strcpy(nume, _nume); | |
| } | |
| void setTelefon(const string &t) {telefon = t;} | |
| void setEmail(const string &e) {email = e;} | |
| void setCompanie(const string &c) {companie = c;} | |
| void setTipMaterial(const string &m) {tipMaterial = m;} | |
| void setNrExemplare(int n) {nrExemplare = n;} | |
| void setDimensiuni(double l, double i) {latime = l; inaltime = i;} | |
| void setCategorie(const string &c) {categorie = c;} | |
| void setCost(double c) {cost = c;} | |
| // | |
| // Operator >- comparatie dupa cost | |
| // | |
| bool operator >=(const CarteDeVizita& other) const { | |
| return this->cost >= other.cost; | |
| } | |
| // | |
| // Operator >> supraincarcat pentru citire de la tastatura | |
| // | |
| friend istream& operator>>(istream &in, CarteDeVizita&c) { | |
| string numeStr; | |
| cout<<" Nume: "; | |
| getline(in, numeStr); | |
| c.setNume(numeStr.c_str()); | |
| cout<<" Telefon: "; | |
| getline(in, c.telefon); | |
| cout<<" Email: "; | |
| getline(in, c.email); | |
| cout<<" Companie: "; | |
| getline(in, c.companie); | |
| cout<<" Tip material (carton/plastic/metal)"; | |
| getline(in, c.tipMaterial); | |
| cout<< "Nr. exemplare"; | |
| //getline(in, c.nrExemplare); | |
| cout<<" Dimensiuni (latime inaltime in cm)"; | |
| in >>c.latime >>c.inaltime; | |
| cout<<" Categorie (business/personal)"; | |
| //in.ignore(); | |
| getline(in, c.categorie); | |
| cout<<" Cost (RON)"; | |
| in>>c.cost; | |
| return in; | |
| } | |
| //----------------------------- | |
| // Operatorul << pentru afisare | |
| //----------------------------- | |
| virtual void afisare(ostream& out) const { | |
| out<<"-----------Carte de vizita ------------\n"; | |
| out<<" Nume: "<<nume<< "\n"; | |
| out<<" Telefon: "<<telefon<< "\n"; | |
| out<<" Email: "<<email<< "\n"; | |
| out<<" Companie: "<<companie<< "\n"; | |
| out<<" Material: "<<tipMaterial<< "\n"; | |
| out<<" Dimensiuni: "<<latime<<"x"<<inaltime<<"cm"<<"\n"; | |
| out<<" Categorie : "<<categorie<< "\n"; | |
| out<<" Cost: "<<cost<< "\n"; | |
| } | |
| friend ostream& operator<<(ostream& out, const CarteDeVizita&c) { | |
| c.afisare(out); | |
| return out; | |
| } | |
| }; | |
| class CarteDeVizitaElectronica: public CarteDeVizita { | |
| private: | |
| string urlProfile; ///ex LinkedIn, sau website personal | |
| string qrCode;//link QR Code | |
| string formatFisier; //vCard, PDF, PNG | |
| bool estePublic; //vizibil pentru public sau nu | |
| public: | |
| //constructorul implicit | |
| CarteDeVizitaElectronica(): CarteDeVizita(), urlProfile(""), qrCode(""), formatFisier("vCard"), estePublic(true){}; | |
| //constructorul cu parametri | |
| CarteDeVizitaElectronica(const char* _nume, const string & _telefon, | |
| const string &_email, const string &_companie, | |
| const string &_url, const string &_qr, | |
| const string &_format, bool _publica): CarteDeVizita(_nume, _telefon, _email, _companie, "electronic", 1, 0.0, 0.0, "digital",0.0), | |
| urlProfile(_url), qrCode(_qr), formatFisier(_format), estePublic(_publica){}; | |
| //constructor de copiere | |
| CarteDeVizitaElectronica(const CarteDeVizitaElectronica&other): CarteDeVizita(other), urlProfile(other.urlProfile), qrCode(other.qrCode), formatFisier(other.formatFisier), estePublic(other.estePublic) {} | |
| ~CarteDeVizitaElectronica() override {} | |
| //getter si setteri | |
| string getUrlProfile() const {return urlProfile;} | |
| string getQrCode() const {return qrCode;} | |
| string getFormatFisier() const {return formatFisier;} | |
| string getEstePublic() const {return estePublic;} | |
| //supraincarcare >> | |
| //virtualizare | |
| void afisare(ostream& out) const override { | |
| ///..... | |
| } | |
| }; | |
| int main(int argc, char const *argv[]) | |
| { | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment