maddie_dlt

account.cpp

Nov 19th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. #include "account.h"
  2. #include <time.h> //_strdate()
  3. #include <iostream>
  4.  
  5. Account::Account()
  6. {
  7. userName = " ";
  8. password = " ";
  9. day = 1;
  10. month = 1;
  11. year = 2016;
  12. skin = 1;
  13. eyeColor = 1;
  14. hairColor = 1;
  15. gender = 1;
  16. outfit = 1;
  17.  
  18. }
  19. Account::Account(string name, string pass)
  20. {
  21. userName = name;
  22. password = pass;
  23. }
  24. void Account::setUserName(string name)
  25. {
  26. userName = name;
  27. }
  28. void Account::setPassword(string pass)
  29. {
  30. password = pass;
  31. }
  32. void Account::setDay(int d)
  33. {
  34. day = d;
  35. }
  36. void Account::setMonth(int m)
  37. {
  38. month = m;
  39. }
  40. void Account::setYear(int y)
  41. {
  42. year = y;
  43. }
  44. void Account::setSkin(int s)
  45. {
  46. skin = s;
  47. }
  48. void Account::setEyeColor(int eye)
  49. {
  50. eyeColor = eye;
  51. }
  52. void Account::setHairColor(int hair)
  53. {
  54. hairColor = hair;
  55. }
  56. void Account::setGender(int g)
  57. {
  58. gender = g;
  59. }
  60. void Account::setOutfit(int otf)
  61. {
  62. outfit = otf;
  63. }
  64. string Account::getUserName() const
  65. {
  66. return userName;
  67. }
  68. string Account::getPassword() const
  69. {
  70. return password;
  71. }
  72. int Account::getSkin() const
  73. {
  74. return skin;
  75. }
  76. int Account::getEyeColor() const
  77. {
  78. return eyeColor;
  79. }
  80. int Account::getHairColor() const
  81. {
  82. return hairColor;
  83. }
  84. int Account::getGender() const
  85. {
  86. return gender;
  87. }
  88. int Account::getOutfit() const
  89. {
  90. return outfit;
  91. }
  92. bool Account::isOldEnough() const
  93. {
  94. int year1 = year;
  95. int month1 = month;
  96. int day1 = day;
  97. int day2 = 0;
  98. int month2 = 0;
  99. int year2 = 0;
  100. bool isOld = true;
  101.  
  102. if( year1 < 2000 )
  103. year1 = 100 - year1 % 100;
  104. if( year > 2000 )
  105. year1 = 0 - year1 % 100;
  106. char date [9];
  107.  
  108. _strdate(date);
  109.  
  110. for(int i = 7; i >= 0; i--)
  111. {
  112. if( i == 7 )
  113. {
  114. year2 = (int) date[i] - 48;
  115. }
  116.  
  117. if( i == 6 )
  118. {
  119. year2 += ((int) date[i] - 48 ) * 10;
  120. }
  121.  
  122. if( i == 4 )
  123. month2 = (int) date[i-3] - 48;
  124.  
  125.  
  126. if( i == 3 )
  127. {
  128. month2 += ((int) date[i-3] - 48 ) * 10;
  129. if( year1 + year2 == 18 && month1 - month2 > 0 )
  130. i-= 10;
  131. }
  132.  
  133. if( i == 1 )
  134. day2 = (int) date[i+3] - 48;
  135.  
  136.  
  137. if( i == 0 )
  138. {
  139. day2 += ((int) date[i+3] - 48 ) * 10;
  140.  
  141. if( year1 + year2 == 18 && month1 - month2 <= 0 && day1 - day2 >= 0)
  142. isOld = false;
  143. }
  144. }
  145.  
  146. return isOld;
  147. }
Add Comment
Please, Sign In to add comment