Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class Processzor {
- private:
- string tipus;
- int labak_szama;
- double sebesseg;
- public:
- Processzor() : tipus(""), labak_szama(0), sebesseg(0.0) {}
- Processzor(string t, int l, double s) : tipus(t), labak_szama(l), sebesseg(s) {}
- ~Processzor() {}
- Processzor& Processzor::operator=(const Processzor &proc) {
- this->tipus = proc.tipus;
- this->labak_szama = proc.labak_szama;
- this->sebesseg = proc.sebesseg;
- return *this;
- }
- double getSebesseg() {
- return sebesseg;
- }
- int getLaba_szama() {
- return labak_szama;
- }
- string getTipus() {
- return tipus;
- }
- Processzor& operator++() {
- if(sebesseg>1000) {
- cerr << "A processzor sebessege tullepte az 1000 muvelet/masodpercet" << endl;
- } else {
- sebesseg+=100;
- }
- }
- };
- class Alaplap {
- private:
- int kapacitas;
- int hany_van;
- Processzor* procik;
- double osszsebesseg;
- public:
- Alaplap() : kapacitas(), hany_van(), procik() {}
- Alaplap(int k) {
- hany_van = 0;
- kapacitas = k;
- procik = new Processzor[kapacitas];
- }
- ~Alaplap() {
- delete[] procik;
- }
- Alaplap& operator+(Processzor& proci) {
- if(hany_van<kapacitas) {
- procik[hany_van]=proci;
- } else {
- cerr << "Nincs tobb hely az alaplapon!" << endl;
- }
- }
- double futtat (int muvelet) {
- if(hany_van==0) {
- cerr << "Nincs processzor az alaplapban" << endl;
- } else {
- for(int i=0; i<hany_van; i++) {
- osszsebesseg = osszsebesseg + procik[i].getSebesseg();
- }
- return muvelet/osszsebesseg;
- }
- }
- friend ostream& operator<<(ostream& os, Alaplap& procik) {
- for(int i=0; i<procik.hany_van; i++) {
- os << "Tipus: " << procik[i].getTipus() << "Labak szama: " << procik[i].getLabak_szama() << "Sebesseg :" << procik[i]getSebesseg() << endl;
- }
- return os;
- }
- };
- int main () {
- Processzor proci1;
- Processzor proci2;
- Alaplap alaplap;
- ++proci1;
- ++proci1;
- ++proci2;
- alaplap.futtat(5);
- cout << alaplap;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement