Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "account.h"
- #include <time.h> //_strdate()
- #include <iostream>
- Account::Account()
- {
- userName = " ";
- password = " ";
- day = 1;
- month = 1;
- year = 2016;
- skin = 1;
- eyeColor = 1;
- hairColor = 1;
- gender = 1;
- outfit = 1;
- }
- Account::Account(string name, string pass)
- {
- userName = name;
- password = pass;
- }
- void Account::setUserName(string name)
- {
- userName = name;
- }
- void Account::setPassword(string pass)
- {
- password = pass;
- }
- void Account::setDay(int d)
- {
- day = d;
- }
- void Account::setMonth(int m)
- {
- month = m;
- }
- void Account::setYear(int y)
- {
- year = y;
- }
- void Account::setSkin(int s)
- {
- skin = s;
- }
- void Account::setEyeColor(int eye)
- {
- eyeColor = eye;
- }
- void Account::setHairColor(int hair)
- {
- hairColor = hair;
- }
- void Account::setGender(int g)
- {
- gender = g;
- }
- void Account::setOutfit(int otf)
- {
- outfit = otf;
- }
- string Account::getUserName() const
- {
- return userName;
- }
- string Account::getPassword() const
- {
- return password;
- }
- int Account::getSkin() const
- {
- return skin;
- }
- int Account::getEyeColor() const
- {
- return eyeColor;
- }
- int Account::getHairColor() const
- {
- return hairColor;
- }
- int Account::getGender() const
- {
- return gender;
- }
- int Account::getOutfit() const
- {
- return outfit;
- }
- bool Account::isOldEnough() const
- {
- int year1 = year;
- int month1 = month;
- int day1 = day;
- int day2 = 0;
- int month2 = 0;
- int year2 = 0;
- bool isOld = true;
- if( year1 < 2000 )
- year1 = 100 - year1 % 100;
- if( year > 2000 )
- year1 = 0 - year1 % 100;
- char date [9];
- _strdate(date);
- for(int i = 7; i >= 0; i--)
- {
- if( i == 7 )
- {
- year2 = (int) date[i] - 48;
- }
- if( i == 6 )
- {
- year2 += ((int) date[i] - 48 ) * 10;
- }
- if( i == 4 )
- month2 = (int) date[i-3] - 48;
- if( i == 3 )
- {
- month2 += ((int) date[i-3] - 48 ) * 10;
- if( year1 + year2 == 18 && month1 - month2 > 0 )
- i-= 10;
- }
- if( i == 1 )
- day2 = (int) date[i+3] - 48;
- if( i == 0 )
- {
- day2 += ((int) date[i+3] - 48 ) * 10;
- if( year1 + year2 == 18 && month1 - month2 <= 0 && day1 - day2 >= 0)
- isOld = false;
- }
- }
- return isOld;
- }
Add Comment
Please, Sign In to add comment