Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Rabotnik{
- private:
- char name[30];
- char surname[30];
- int salary;
- public:
- Rabotnik(){}
- Rabotnik(const char * ime, const char * prezime, int plata);
- int getPlata();
- void pecati();
- };
- Rabotnik::Rabotnik(const char * ime, const char * prezime, int plata){
- strcpy(this->name, ime);
- strcpy(this->surname, prezime);
- this->salary=plata;
- }
- int Rabotnik::getPlata(){
- return this->salary;
- }
- void Rabotnik::pecati(){
- cout << this->name << " " << this->surname << " " << this->getPlata() << endl;
- }
- //class Fabrika
- class Fabrika {
- private:
- Rabotnik array[100];
- int brojVraboteni;
- public:
- Fabrika(){}
- Fabrika(const Rabotnik * r, int n);
- void pecatiVraboteni();
- void pecatiSoPlata(int plata);
- };
- Fabrika::Fabrika(const Rabotnik * r, int n){
- for(int i=0; i<n; i++){
- this->array[i] = *(r+i);
- }
- this->brojVraboteni=n;
- }
- void Fabrika::pecatiVraboteni(){
- cout << "Site vraboteni:" << endl;
- for(int i=0; i<this->brojVraboteni; i++){
- this->array[i].pecati();
- }
- }
- void Fabrika::pecatiSoPlata(int plata){
- cout << "Vraboteni so plata povisoka od " << plata << " :" << endl;
- for(int i=0; i<this->brojVraboteni; i++){
- if((this->array[i].getPlata()) > plata){
- this->array[i].pecati();
- }
- }
- }
- int main(void){
- char name[30], surname[30];
- int salary, minSalary;
- Rabotnik r[100];
- int n;
- cin>>n;
- for(int i=0; i<n; i++){
- cin >> name;
- cin >> surname;
- cin >> salary;
- r[i] = Rabotnik(name,surname,salary);
- }
- Fabrika f(r,n);
- cin >> minSalary;
- f.pecatiVraboteni();
- f.pecatiSoPlata(minSalary);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement