Example #1
0
        public Person(string name, string surname, string email, DateTime dateOfBirth)
        {
            IsCorrectDateOfBirth(dateOfBirth);
            IsEmailValid(email);
            Name        = name;
            Surname     = surname;
            Email       = email;
            DateOfBirth = dateOfBirth;
            OperateZodiac zodiac = new OperateZodiac();

            _isAdult     = CalcAdult();
            _sunSign     = zodiac.FindWestZodiac(DateOfBirth);
            _chineseSign = zodiac.FindChineseZodiac(DateOfBirth.Year);
            _isBirthday  = zodiac.isBirthday(DateOfBirth);
        }
Example #2
0
        public Person(string email, string name, string surname, DateTime dateOfBirth)
        {
            Email       = email;
            Name        = name;
            Surname     = surname;
            DateOfBirth = dateOfBirth;
            OperateZodiac zodiac = new OperateZodiac();

            _westernZodiac = zodiac.FindWestZodiac(DateOfBirth);
            _chineseZodiac = zodiac.FindChineseZodiac(DateOfBirth.Year);
            _isBirthday    = zodiac.isBirthday(DateOfBirth);
            if (DateTime.Today > DateOfBirth)
            {
                if (DateTime.Today.Month > DateOfBirth.Month)
                {
                    Age = DateTime.Today.Year - DateOfBirth.Year;
                }
                else if (DateTime.Today.Month == DateOfBirth.Month && DateTime.Today.Day > DateOfBirth.Day)
                {
                    Age = DateTime.Today.Year - DateOfBirth.Year;
                }
                else if (DateTime.Today.Month == DateOfBirth.Month && DateTime.Today.Day == DateOfBirth.Day)
                {
                    Age = DateTime.Today.Year - DateOfBirth.Year;
                }
                else
                {
                    Age = DateTime.Today.Year - DateOfBirth.Year - 1;
                }
            }
            else
            {
                Age = 0;
            }
            _isAdult = CalcAdult();
        }