Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include "Spieler.h"
  2. #include "Mannschaft.h"
  3.   vector<string> position_namen {"Tor", "Abwehr", "Mitte", "Sturm"};
  4.  
  5.   Spieler::Spieler(string name, int transSum, Position position) {
  6.    
  7.    
  8.     if (name.size() < 1)
  9.       throw runtime_error("Name!!");
  10.    
  11.    
  12.     if (transSum < 10 || transSum > 500)
  13.       throw runtime_error("Summe!!");
  14.    
  15.     if (position == Position::Tor)
  16.       n = 0;
  17.     if (position == Position::Abwehr)
  18.       n = 1;
  19.     if (position == Position::Mitte)
  20.       n = 2;
  21.     if (position == Position::Sturm)
  22.       n = 3;
  23.     this-> name = name;
  24.     this-> transSum = transSum;
  25.   }
  26.  
  27.   string Spieler::getName() {return this->name;}
  28.  
  29.  
  30.   bool Spieler::operator==(const Spieler& s) const{
  31.     return (name == s.name);
  32.   }
  33.  
  34.   ostream& operator<< (ostream& o, const Spieler& s) {
  35.     return s.print(o);
  36.   }
  37.  
  38.   ostream& Spieler::print(ostream& o) const {
  39.     o << "[" << name << ", " << transSum << " Mio Euro, " << position_namen.at(n) << "]";
  40.     return o;
  41.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement