Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * <one line to give the program's name and a brief idea of what it does.>
- * Copyright 2020 <copyright holder> <email>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License or (at your option) version 3 or any later version
- * accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
- * defined in Section 14 of version 3 of the license.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "collaborators.h"
- Collaborators::Collaborators()
- {
- id = 0;
- surname = "Type in:";
- byear = 2000;
- sex = "male";
- }
- Collaborators::Collaborators(int colid, std::string surn, int year, std::string csex)
- {
- id = colid;
- surname = surn;
- byear = year;
- sex=csex;
- }
- std::string Collaborators::get() const
- {
- std::string value = std::to_string(id) + "\n" + surname + "\n" + std::to_string(byear) + "\n" +sex+"\n";
- return value;
- }
- void Collaborators::set(int colid, std::string surn, int year, std::string csex)
- {
- id = colid;
- surname = surn;
- byear = year;
- sex = csex;
- }
- void Collaborators::input()
- {
- std::cout<< "Please enter your id: ";
- std::cin>>id;
- std::cout<<"Please enter your surname: ";
- std::cin>>surname;
- std::cout<<"Please enter you birth year: ";
- std::cin>>byear;
- std::cout<<"Please enter your gender: ";
- std::cin>>sex;
- std::cout<<"Thank you! You are now signed up!"<<std::endl;
- }
- bool operator < (Collaborators col1, Collaborators col2)
- {
- if(col1.surname == col2.surname)
- return col1.id<col2.id;
- else
- return col1.surname<col2.surname;
- }
- bool operator >(Collaborators col1, Collaborators col2)
- {
- if(col1.surname == col2.surname)
- return col1.id>col2.id;
- else
- return col1.surname>col2.surname;
- }
- std::ostream& operator <<(std::ostream& os, const Collaborators& col)
- {
- os<<col.get()<<std::endl;
- return os;
- }
Add Comment
Please, Sign In to add comment