Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created April 5, 2026 15:01
Show Gist options
  • Select an option

  • Save thinkphp/4fc8d11020c14fbd3ab8549a59bba381 to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/4fc8d11020c14fbd3ab8549a59bba381 to your computer and use it in GitHub Desktop.
Proiect numarul 2 Angajat, Inginer, Muncitor
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//===============================================
// CLASA ABSTRACTA ANGAJAT
//===============================================
class Angajat {
protected:
int marca;
string nume;
public:
//constructorul clasei
Angajat(int m, const string& n): marca( m ), nume( n ) {}
//destructor virtual
virtual ~Angajat() {}
//functii de access : getter si setter
int getMarca() const { return marca; }
string getNume() const { return nume; }
//setters
void setMarca(int m) { marca = m; }
void setNume(const string &n) { nume = n; }
//metoda ABSTRACTA de calcul SALARIU
virtual double calcSalariu() const = 0;
//Operator afisare : marca, nume si salariul
friend ostream& operator<< (ostream& os, const Angajat& a) {
os << a.marca<<", "<<a.nume<<", "<<a.calcSalariu();
return os;
}
};
//===============================================
// CLASA INGINER
//===============================================
class Inginer: public Angajat {
private:
int nrOre;
double salariuOrar;
double sporTime; //procent spor 10%
public:
//constructorul clasei
Inginer(int marca, const string& nume, int nrOre, double salariuOrar, double sporTime)
:Angajat(marca, nume), nrOre(nrOre), salariuOrar(salariuOrar), sporTime(sporTime) {}
//functii de access
//gettters
int getNrOre() const { return nrOre; }
double getSalariuOrar() const { return salariuOrar; }
double getSporTime() const { return sporTime; }
//setters;
void setNrOre(int n) {nrOre = n;}
void setSalariuOrar(double s) { salariuOrar = s;}
void setSporTime(double s) { sporTime = s;}
//calcul salariu: ore * salariu_orar * (1 + spor)
double calcSalariu() const override {
return nrOre * salariuOrar * (1.0 + sporTime);
}
};
//===============================================
// CLASA Muncitor derivata din Angajat
//===============================================
class Muncitor: public Angajat {
private:
int nrPiese;
double monoperaPePiese;
public:
//constructorul clasei;
Muncitor(int marca, const string& nume, int nrPiese, double monoperaPePiese)
: Angajat(marca, nume), nrPiese(nrPiese), monoperaPePiese(monoperaPePiese) {}
//functii de access: gettters si setters
int getNrPiese() const {return nrPiese;}
double getManoperaPePiesa() const {return monoperaPePiese; }
//setters
void setNrPiese(int n) {nrPiese = n;}
void setManoperaPePiese(double m) { monoperaPePiese = m; }
//calcul salariu: nr_piese * manopera_pe_piesa
double calcSalariu() const override {
return nrPiese * monoperaPePiese;
}
};
int main(int argc, char const *argv[])
{
/* code */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment