Advertisement
Guest User

Updated user.cpp

a guest
Mar 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.60 KB | None | 0 0
  1. /*
  2.  * User.cpp
  3.  *
  4.  *  Created on: Mar 9, 2018
  5.  *      Author: joewy
  6.  */
  7.  
  8. #include "User.h"
  9. #include "BST.h"
  10.  
  11.     /**Constructors*/
  12. User::User():firstName(""), lastName(""), userName(""), passWord(""), city(""), state(""), ID(-1){};
  13.  
  14. User::User(string f, string l, string u, string p, string c, string s, unsigned id)
  15. {
  16.     firstName = f;
  17.     lastName = l;
  18.     userName = u;
  19.     passWord = p;
  20.     city = c;
  21.     state = s;
  22.     ID = id;
  23.  
  24. }
  25.  
  26. /**Access Functions*/
  27. unsigned User::getID() const
  28. {
  29.     return ID;
  30. }
  31.  
  32. string User::getFirstname() const
  33. {
  34.     return firstName;
  35. }
  36.  
  37. string User::getLastname() const
  38. {
  39.     return lastName;
  40. }
  41.  
  42. string User::getCity() const
  43. {
  44.     return city;
  45. }
  46.  
  47. string User::getState() const
  48. {
  49.     return state;
  50. }
  51.  
  52. string User::getUsername() const
  53. {
  54.     return userName;
  55. }
  56.  
  57. string User::getPassword() const
  58. {
  59.     return passWord;
  60. }
  61.  
  62. List<string> User::getInterest() const
  63. {
  64.     return interests;
  65. }
  66.  
  67. List<string> User::getFriend() const
  68. {
  69.     return friends;
  70. }
  71.  
  72. BST<string> User::getBST()
  73. {
  74.     return FriendList;
  75. }
  76.  
  77. bool User::searchFriend(string name) const
  78. {
  79.     bool searchFr;
  80.     searchFr = friendBST.search(name);
  81.     return searchFr;
  82. }
  83.  
  84. void User::printFriends() const
  85. {
  86.     friendBST.inOrderPrint(cout);
  87. }
  88.  
  89. /**Manipulation Procedures*/
  90.  
  91.  
  92. void User::setFirstname(string f)
  93. {
  94.     firstName = f;
  95. }
  96.  
  97. void User::setLastname(string l)
  98. {
  99.     lastName = l;;
  100. }
  101.  
  102. void User::setFriends(string fr)
  103. {
  104.     friends.insertLast(fr);
  105.     friendBST.insert(fr);
  106.     FriendList.insert(fr);
  107. }
  108.  
  109. void User::removeFriend(string fr)
  110. {
  111.     friendBST.remove(fr);
  112. }
  113.  
  114. void User::setInterests(string i)
  115. {
  116.     interests.insertLast(i);
  117. }
  118.  
  119. void User::setFriendList(string u)
  120. {
  121.     FriendList.insert(u);
  122. }
  123. /**Additional Functions*/
  124.  
  125. ostream& operator<<(ostream& out, const User &user)
  126. {
  127.     out << user.firstName << " " << user.lastName << endl;
  128.     out << "From: " << user.city << ", " << user.state << endl;
  129.     out << "friends: ";
  130.     user.friends.printList(out);
  131.     out << "interests: ";
  132.     user.interests.printList(out);
  133.     return out;
  134. }
  135.  
  136. bool User::operator==(const User& user)
  137. {
  138.     return (firstName == user.firstName && lastName == user.lastName);
  139. }
  140.  
  141. bool User::operator<(const User& user)
  142. {
  143.     if(firstName < user.firstName)
  144.         return true;
  145.     else if(firstName == user.firstName)
  146.     {
  147.         if(lastName < user.lastName)
  148.             return true;
  149.         else
  150.             return false;
  151.     }
  152.     else
  153.         return false;
  154. }
  155.  
  156. bool User::operator>(const User& user)
  157. {
  158.     if(firstName > user.firstName)
  159.         return true;
  160.     else if(firstName == user.firstName)
  161.     {
  162.         if(lastName > user.lastName)
  163.             return true;
  164.         else
  165.             return false;
  166.     }
  167.     else
  168.         return false;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement