Advertisement
Guest User

User.cpp

a guest
Mar 22nd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.49 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::getUsername() const
  48. {
  49.     return userName;
  50. }
  51.  
  52. List<string> User::getInterest() const
  53. {
  54.     return interests;
  55. }
  56.  
  57. List<string> User::getFriend() const
  58. {
  59.     return friends;
  60. }
  61. bool User::searchFriend(string name) const
  62. {
  63.     bool searchFr;
  64.     searchFr = friendBST.search(name);
  65.     return searchFr;
  66. }
  67.  
  68. void User::printFriends() const
  69. {
  70.     friendBST.inOrderPrint(cout);
  71. }
  72.  
  73. /**Manipulation Procedures*/
  74.  
  75.  
  76. void User::setFirstname(string f)
  77. {
  78.     firstName = f;
  79. }
  80.  
  81. void User::setLastname(string l)
  82. {
  83.     lastName = l;;
  84. }
  85.  
  86. void User::setFriends(string fr)
  87. {
  88.     friends.insertLast(fr);
  89.     friendBST.insert(fr);
  90. }
  91.  
  92. void User::removeFriend(string fr)
  93. {
  94.     friendBST.remove(fr);
  95. }
  96.  
  97. void User::setBST(User u)
  98. {
  99.     friendUser.insert(u);
  100. }
  101. BST<User> User::getBST()
  102. {
  103.     //friendUser.inOrderPrint(cout);
  104.     return friendUser;
  105. }
  106.  
  107. void User::setInterests(string i)
  108. {
  109.     interests.insertLast(i);
  110. }
  111.  
  112. /**Additional Functions*/
  113.  
  114. ostream& operator<<(ostream& out, const User &user)
  115. {
  116.     out << user.firstName << " " << user.lastName << endl;
  117.     out << "From: " << user.city << ", " << user.state << endl;
  118.     out << "friends: ";
  119.     user.friends.printList(out);
  120.     out << "interests: ";
  121.     user.interests.printList(out);
  122.     return out;
  123. }
  124.  
  125. bool User::operator==(const User& user)
  126. {
  127.     return (firstName == user.firstName && lastName == user.lastName);
  128. }
  129.  
  130. bool User::operator<(const User& user)
  131. {
  132.     if(firstName < user.firstName)
  133.         return true;
  134.     else if(firstName == user.firstName)
  135.     {
  136.         if(lastName < user.lastName)
  137.             return true;
  138.         else
  139.             return false;
  140.     }
  141.     else
  142.         return false;
  143. }
  144.  
  145. bool User::operator>(const User& user)
  146. {
  147.     if(firstName > user.firstName)
  148.         return true;
  149.     else if(firstName == user.firstName)
  150.     {
  151.         if(lastName > user.lastName)
  152.             return true;
  153.         else
  154.             return false;
  155.     }
  156.     else
  157.         return false;
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement