CaptainManiac999

Collaborators.cpp

Sep 25th, 2020 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.45 KB | None | 0 0
  1. /*
  2.  * <one line to give the program's name and a brief idea of what it does.>
  3.  * Copyright 2020  <copyright holder> <email>
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License as
  7.  * published by the Free Software Foundation; either version 2 of
  8.  * the License or (at your option) version 3 or any later version
  9.  * accepted by the membership of KDE e.V. (or its successor approved
  10.  * by the membership of KDE e.V.), which shall act as a proxy
  11.  * defined in Section 14 of version 3 of the license.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  */
  21.  
  22.  
  23. #include "collaborators.h"
  24.  
  25. Collaborators::Collaborators()
  26. {
  27.     id = 0;
  28.     surname = "Type in:";
  29.     byear = 2000;
  30.     sex = "male";
  31. }
  32.  
  33. Collaborators::Collaborators(int colid, std::string surn, int year, std::string csex)
  34. {
  35.     id = colid;
  36.     surname = surn;
  37.     byear = year;
  38.     sex=csex;
  39. }
  40.  
  41.  
  42. std::string Collaborators::get() const
  43. {
  44.     std::string value = std::to_string(id) + "\n" + surname + "\n" + std::to_string(byear) + "\n" +sex+"\n";
  45.     return value;
  46. }
  47.  
  48. void  Collaborators::set(int colid, std::string surn, int year, std::string csex)
  49. {
  50.     id = colid;
  51.     surname = surn;
  52.     byear = year;
  53.     sex = csex;
  54. }
  55.  void Collaborators::input()
  56. {
  57.     std::cout<< "Please enter your id: ";
  58.     std::cin>>id;
  59.     std::cout<<"Please enter your surname: ";
  60.     std::cin>>surname;
  61.     std::cout<<"Please enter you birth year: ";
  62.     std::cin>>byear;
  63.     std::cout<<"Please enter your gender: ";
  64.     std::cin>>sex;
  65.     std::cout<<"Thank you! You are now signed up!"<<std::endl;
  66. }
  67.  
  68. bool operator < (Collaborators col1, Collaborators col2)
  69. {
  70.     if(col1.surname == col2.surname)
  71.         return col1.id<col2.id;
  72.     else
  73.         return col1.surname<col2.surname;
  74. }
  75.  
  76. bool operator >(Collaborators col1, Collaborators col2)
  77. {
  78. if(col1.surname == col2.surname)
  79.     return col1.id>col2.id;
  80. else
  81.     return col1.surname>col2.surname;
  82. }
  83.  
  84. std::ostream& operator <<(std::ostream& os, const Collaborators& col)
  85. {
  86.  os<<col.get()<<std::endl;
  87.  return os;
  88. }
  89.  
Add Comment
Please, Sign In to add comment