Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3.  
  4. using namespace std;
  5.  
  6. class Processzor {
  7. private:
  8.     string tipus;
  9.     int labak_szama;
  10.     double sebesseg;
  11. public:
  12.     Processzor() : tipus(""), labak_szama(0), sebesseg(0.0) {}
  13.     Processzor(string t, int l, double s) : tipus(t), labak_szama(l), sebesseg(s) {}
  14.     ~Processzor() {}
  15.    
  16.     Processzor& Processzor::operator=(const Processzor &proc) {
  17.         this->tipus = proc.tipus;
  18.         this->labak_szama = proc.labak_szama;
  19.         this->sebesseg = proc.sebesseg;
  20.  
  21.         return *this;
  22.     }
  23.  
  24.     double getSebesseg() {
  25.         return sebesseg;
  26.     }
  27.  
  28.     int getLaba_szama() {
  29.         return labak_szama;
  30.     }
  31.  
  32.     string getTipus() {
  33.         return tipus;
  34.     }
  35.  
  36.     Processzor& operator++() {
  37.         if(sebesseg>1000) {
  38.             cerr << "A processzor sebessege tullepte az 1000 muvelet/masodpercet" << endl;
  39.         } else {
  40.             sebesseg+=100;
  41.         }
  42.     }
  43. };
  44.  
  45. class Alaplap {
  46. private:
  47.     int kapacitas;
  48.     int hany_van;
  49.     Processzor* procik;
  50.     double osszsebesseg;
  51. public:
  52.     Alaplap() : kapacitas(), hany_van(), procik() {}
  53.     Alaplap(int k) {
  54.     hany_van = 0;
  55.     kapacitas = k;
  56.     procik = new Processzor[kapacitas];
  57.     }
  58.     ~Alaplap() {
  59.         delete[] procik;
  60.     }
  61.  
  62.     Alaplap& operator+(Processzor& proci) {
  63.         if(hany_van<kapacitas) {
  64.             procik[hany_van]=proci;
  65.         } else {
  66.             cerr << "Nincs tobb hely az alaplapon!" << endl;
  67.         }
  68.     }
  69.  
  70.     double futtat (int muvelet) {
  71.         if(hany_van==0) {
  72.             cerr << "Nincs processzor az alaplapban" << endl;
  73.         } else {
  74.             for(int i=0; i<hany_van; i++) {
  75.                 osszsebesseg = osszsebesseg + procik[i].getSebesseg();
  76.             }
  77.             return muvelet/osszsebesseg;
  78.         }
  79.     }
  80.  
  81.     friend ostream& operator<<(ostream& os, Alaplap& procik) {
  82.         for(int i=0; i<procik.hany_van; i++) {
  83.                 os << "Tipus: " << procik[i].getTipus() << "Labak szama: " << procik[i].getLabak_szama() << "Sebesseg :" << procik[i]getSebesseg() << endl;
  84.         }
  85.         return os;
  86.     }
  87.  
  88. };
  89.  
  90. int main () {
  91.     Processzor proci1;
  92.     Processzor proci2;
  93.  
  94.     Alaplap alaplap;
  95.  
  96.     ++proci1;
  97.     ++proci1;
  98.     ++proci2;
  99.  
  100.     alaplap.futtat(5);
  101.  
  102.     cout << alaplap;
  103.    
  104.  
  105.     return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement