SHARE
TWEET

lab4zad2

michalkowalczyk Mar 27th, 2019 66 in 159 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<person.h>
  2.  
  3.  
  4.  
  5. person::person(const std::string &fullName){
  6.  
  7.     std::stringstream iss(fullName);
  8.     std::vector<std::string> tokens{std::istream_iterator<std::string>{iss},std::istream_iterator<std::string>{}};
  9.  
  10.     if(tokens.size()==4){
  11.         first_Name=tokens[0];
  12.         second_Name=tokens[1];
  13.         third_Name=tokens[2];
  14.         _Surname=tokens[3];
  15.  
  16.  
  17.     }
  18.     else if (tokens.size()==3) {
  19.         first_Name=tokens[0];
  20.         second_Name=tokens[1];
  21.         third_Name="";
  22.         _Surname=tokens[2];
  23.     }
  24.     else if (tokens.size()==2) {
  25.         first_Name=tokens[0];
  26.         second_Name="";
  27.         third_Name="";
  28.         _Surname=tokens[1];
  29.     }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. }
  37.  
  38. std:: string person::firstName()const{
  39.  
  40.     return first_Name;
  41. }
  42.  
  43. std:: string person::secondName()const{
  44.  
  45.     return second_Name;
  46. }
  47.  
  48. std:: string person::thirdName()const{
  49.  
  50.     return third_Name;
  51. }
  52.  
  53. std:: string person::Surname()const{
  54.  
  55.     return _Surname;
  56. }
  57.  
  58. std::string person::ToFullInitials() const{
  59.  
  60.     std::string result="";
  61.  
  62.     result += first_Name[0];
  63.     result += ". ";
  64.  
  65.     if(second_Name!=""){
  66.     result += second_Name[0];
  67.     result += ". ";}
  68.  
  69.     if(third_Name!=""){
  70.     result += third_Name[0];
  71.     result += ". ";}
  72.  
  73.     result += _Surname[0];
  74.     result += ". ";
  75.  
  76.     return result;
  77. }
  78.  
  79.  
  80. std::string person::ToFirstNamesInitials() const{
  81.  
  82.     std::string result="";
  83.  
  84.     result += first_Name[0];
  85.     result += ". ";
  86.  
  87.     if(second_Name!=""){
  88.     result += second_Name[0];
  89.     result += ". ";}
  90.  
  91.     if(third_Name!=""){
  92.     result += third_Name[0];
  93.     result += ". ";}
  94.  
  95.     result+=_Surname;
  96.  
  97.     return result;
  98.  
  99. }
  100.  
  101. std:: string person::ToSurnameNames() const{
  102.  
  103.     std::string result="";
  104.  
  105.     result+=_Surname;
  106.     result += " ";
  107.  
  108.     result += first_Name;
  109.     result += " ";
  110.  
  111.     if(second_Name!=""){
  112.     result += second_Name;
  113.     result += " ";}
  114.  
  115.     if(third_Name!=""){
  116.     result += third_Name;
  117.     result += " ";}
  118.  
  119.  
  120.  
  121.     return result;
  122.  
  123.  
  124. }
  125.  
  126. std::string person::ToNamesSurname() const{
  127.  
  128.  
  129.     std::string result="";
  130.  
  131.  
  132.  
  133.     result += first_Name;
  134.     result += " ";
  135.  
  136.     if(second_Name!=""){
  137.     result += second_Name;
  138.     result += " ";}
  139.  
  140.     if(third_Name!=""){
  141.     result += third_Name;
  142.     result += " ";}
  143.  
  144.     result+=_Surname;
  145.     result += " ";
  146.  
  147.  
  148.     return result;
  149. }
  150.  
  151. bool person::IsBeforeBySurname(const person &other) const{
  152.     bool check=false;
  153.  
  154.     if(this->_Surname<other._Surname)
  155.         check=true;
  156.  
  157.  
  158.  
  159.     return check;
  160. }
  161.  
  162.  
  163. bool person::IsBeforeByFirstName(const person &other) const{
  164.     bool check=false;
  165.  
  166.     if(this->first_Name<other.first_Name)
  167.         check=true;
  168.  
  169.  
  170.     return check;
  171. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top