avocat poo

Upload: andrushee

Post on 25-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Avocat poo

    1/5

    #include#include#include#include#include#include

    using namespace std;

    class Avocat{private:

    const int cod;char* nume;int onorariu;int numarProcese;int* vectorProcese;

    public:Avocat() :cod(0){

    this->nume = new char[strlen("Implicit") + 1];strcpy(this->nume, "Implicit");

    this->onorariu = 0;this->numarProcese = 0;this->vectorProcese = new int[numarProcese];

    for (int i = 0; i < numarProcese; i++)this->vectorProcese[i] = vectorProcese[i];

    }

    Avocat(const int cod,char* nume, int onorariu, int numarProcese, int* vectorProcese) :cod(cod)

    {this->nume = new char[strlen(nume) + 1];strcpy(this->nume, nume);this->onorariu = onorariu;

    this->numarProcese = numarProcese;this->vectorProcese = new int[numarProcese];for (int i = 0; i < numarProcese; i++)

    this->vectorProcese[i] = vectorProcese[i];}Avocat(Avocat & a) :cod(cod){

    this->nume = new char[strlen(a.nume) + 1];strcpy(this->nume, a.nume);this->onorariu = a.onorariu;this->numarProcese = a.numarProcese;this->vectorProcese = new int[a.numarProcese];for (int i = 0; i < a.numarProcese; i++)

    this->vectorProcese[i] = a.vectorProcese[i];}Avocat &operator=(Avocat & a){

    if (this->nume)delete[]this->nume;

    this->nume = new char[strlen(a.nume) + 1];strcpy(this->nume, a.nume);this->onorariu = a.onorariu;this->numarProcese = a.numarProcese;

  • 7/25/2019 Avocat poo

    2/5

    if (this->vectorProcese)delete[]this->vectorProcese;

    this->vectorProcese = new int[a.numarProcese];for (int i = 0; i < a.numarProcese; i++)

    this->vectorProcese[i] = a.vectorProcese[i];return *this;

    }~Avocat(){

    if (this->nume)delete[] this->nume;

    if (this->vectorProcese)delete[] this->vectorProcese;

    }void setNume(char* nume){

    this->nume = new char[strlen(nume) + 1];strcpy(this->nume, nume);

    }void setOnorariu(int onorariu){

    this->onorariu = onorariu;}void setNumarProcese(int numarProcese)

    { this->numarProcese = numarProcese;}void setVectoriProcese(int* vectorProcese,int nr){

    this->vectorProcese = new int[nr];for (int i = 0; i < nr; i++)

    this->vectorProcese[i] = vectorProcese[i];}char* getNume(){

    return this->nume;}

    int getOnorariu(){return this->onorariu;

    }int getNumarProcese(){

    return this->numarProcese;}int* getVectorProcese(){

    for (int i = 0; i < numarProcese; i++)return this->vectorProcese;

    }

    int getCod(){

    return this->cod;}friend ostream &operator(istream&, Avocat &);friend Avocat operator+=(Avocat &, float);friend Avocat operator-=(Avocat &, float);friend bool operator==(Avocat&, Avocat&);friend bool operator

  • 7/25/2019 Avocat poo

    3/5

    friend bool operator>(Avocat&, Avocat&);friend ofstream &operator(ifstream&, Avocat&);

    float valMedieProces(){

    float suma = 0;float valMedie;for (int i = 0; i

  • 7/25/2019 Avocat poo

    4/5

    {if (a.numarProcese < b.numarProcese)

    return 1;else

    return 0;}bool operator>(Avocat & a, Avocat& b){

    if (a.numarProcese > b.numarProcese)return 1;

    elsereturn 0;

    }ostream& operator

  • 7/25/2019 Avocat poo

    5/5

    cout