Guest User

Untitled

a guest
Jan 14th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Drucker
  5. {
  6.     public:
  7.     int papakt, papmax, tinakt, tinmax;
  8.    
  9.  
  10.     Drucker(int papakt=0, int papmax=0, int tinakt=0, int tinmax=0)
  11.     {
  12.         this -> papakt = papakt;
  13.         this -> papmax = papmax;
  14.         this -> tinakt = tinakt;
  15.         this -> tinmax = tinmax;
  16.     }
  17.  
  18.  
  19.     void papNachfuehlen(int anz)
  20.     {
  21.         if((papakt+anz)<papmax)
  22.             papakt=papakt+anz;
  23.        
  24.         else    papakt=papmax;     
  25.     }
  26.  
  27.     void papEntnehmen(int anz)
  28.     {
  29.         if((papakt-anz)>0)
  30.             papakt=papakt-anz;
  31.        
  32.         else    papakt=0;  
  33.     }
  34.  
  35.     void drucken(int anz)
  36.     {
  37.         int hlp = std::min(papakt,tinakt);
  38.         if(anz<hlp)
  39.         {
  40.             papakt=papakt-anz;
  41.             tinakt=tinakt-anz;     
  42.         }
  43.     }
  44.  
  45.  
  46.     void neuerTinte()
  47.     {
  48.         tinakt=tinmax; 
  49.     }
  50.  
  51.          
  52.  
  53.    
  54. };
  55.  
  56. double  operator + (Drucker &d, Drucker &p)
  57.     {
  58.         double a = double(d.tinakt) / double(d.tinmax);
  59.         double b = double(p.tinakt) / double (p.tinmax);
  60.  
  61.         return std::max(a,b);
  62.     }
  63.  
  64. Drucker &operator * (Drucker &a)
  65. {
  66.     Drucker *b = new Drucker;
  67.     b.papmax=a.papmax;
  68.     b.papakt=2*a.papakt;
  69.  
  70.     return b;
  71. }
  72.  
  73.  
  74.  
  75.  
  76. int main()
  77. {
  78.     Drucker d(50,100,40,80), p(25,100,70,100), q;
  79.     double ink = d + p;
  80.     cout << ink<< endl;
  81.     q = 2 * d;
  82.    
  83. }
Advertisement
Add Comment
Please, Sign In to add comment