Advertisement
Holek

Untitled

Jul 2nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. class Uran233{
  6. private:
  7.     double waga;
  8.     bool masaKrytyczna;
  9. public:
  10.     Uran233(double wg){
  11.         this->waga = wg;
  12.         if(this->waga>16){
  13.            this->masaKrytyczna=true;
  14.         }else{
  15.             this->masaKrytyczna=false;
  16.         }
  17.     }
  18.     void setMk(bool v){
  19.         this->masaKrytyczna = v;
  20.     }
  21.     void setWg(double wg){
  22.         this->waga = wg;
  23.     }
  24.     double getWg(){
  25.         return this->waga;
  26.     }
  27.     bool getmK(){
  28.         return this->masaKrytyczna;
  29.     }
  30.  
  31. };
  32. Uran233 operator += (Uran233 &a,double wg){
  33.     a.setWg(a.getWg()+wg);
  34.     if(a.getWg() > 16)
  35.         a.setMk(true);
  36.  
  37. }
  38. Uran233 operator -= (Uran233 &a, double wg){
  39.     a.setWg(a.getWg()-wg);
  40.     if(a.getWg()<16)
  41.         a.setMk(false);
  42. }
  43. int main()
  44. {
  45.     Uran233 a(15);
  46.     cout<<"Waga :"<< a.getWg() << endl << "Masa Kryt ? : "<< a.getmK() << endl;
  47.     a+=10;
  48.     cout<<"Waga :"<< a.getWg() << endl << "Masa Kryt ? : "<< a.getmK() << endl;
  49.     a-=25;
  50.     cout<<"Waga :"<< a.getWg() << endl << "Masa Kryt ? : "<< a.getmK() << endl;
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement