Advertisement
fursty

OOP Kursova WiP

Mar 2nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include <fstream>
  4. #include <algorithm>
  5. #include <iomanip>
  6. #include<vector>
  7.  
  8. using namespace std;
  9.  
  10. class User{
  11. private:
  12. string id_user;
  13. string groupName;
  14. string subGroupName;
  15.  
  16. public:
  17. static string groupNameStat;
  18.  
  19. User()
  20. {
  21. id_user= "";
  22. groupName = "";
  23. subGroupName = "";
  24. }
  25.  
  26. User(string idnum, string group, string subgroup)
  27. {
  28. id_user = idnum;
  29. groupName = group;
  30. subGroupName = subgroup;
  31. }
  32.  
  33. string getId()
  34. {
  35. return id_user;
  36. }
  37.  
  38. string getGroupName()
  39. {
  40. return groupName;
  41. }
  42.  
  43. string geSubGroup()
  44. {
  45. return subGroupName;
  46. }
  47.  
  48. bool operator <(User p)
  49. {
  50. if (id_user.length()<p.id_user.length()) return true;
  51. }
  52.  
  53. bool operator ==(User p)
  54. {
  55. if (p.id_user == id_user){ return true; }
  56. else return false;
  57. }
  58.  
  59. friend ostream& operator <<(ostream& fp, User p)
  60. {
  61. fp << " User ID : " << p.id_name << " Group Name : " << p.groupName <<
  62. "Subgroup Name:" << p.geSubGroup << endl;
  63. return fp;
  64. }
  65.  
  66. friend istream& operator >>(istream& fp, User p)
  67. {
  68. fp >> p.id_user >> p.groupName >> p.subGroupName;
  69. }
  70. };
  71.  
  72. class SocialNet{
  73.  
  74. private:
  75. string networkName;
  76. vector<User>users;
  77.  
  78. public:
  79. SocialNet(string fileName)
  80. {
  81. fstream fp;
  82. string buff;
  83. int pos;
  84. int counter = 0;
  85. fp.open(fileName);
  86. if (fp.is_open())
  87. {
  88. while (getline(fp, buff))
  89. if (counter != 0)
  90. {
  91. pos = buff.find(" ");
  92. users.push_back(User(buff.substr(0, pos), stoi(buff.substr(pos))));
  93. }
  94. else{
  95. networkName = buff;
  96. counter++;
  97. }
  98.  
  99. }
  100. fp.close();
  101. }
  102.  
  103. };
  104.  
  105. int main()
  106. {
  107.  
  108. int choice;
  109.  
  110. do
  111. {
  112.  
  113.  
  114. cout << endl
  115. << " 1. Suzdavane na obekt.\n"
  116. << " 2 - Story.\n"
  117. << " 4 - Help.\n"
  118. << " 5 - Exit.\n"
  119. << " Enter your choice and press return: ";
  120. cin >> choice;
  121.  
  122. switch (choice)
  123. {
  124. case 1:
  125. //code to start the game
  126. break;
  127. case 2:
  128. //code to make score for this game to count how many times u win the game
  129. break;
  130. case 3:
  131. //code to make option for the game
  132. break;
  133. case 4:
  134. //code to help the user like give him
  135. //extra information about the mode and the controller
  136. break;
  137. case 5:
  138. cout << "End of Program.\n";
  139. break;
  140. default:
  141. cout << "Not a Valid Choice. \n"
  142. << "Choose again.\n";
  143. break;
  144. }
  145.  
  146. } while (choice != 5);
  147. return 0;
  148. }
  149.  
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement