Пример #1
0
        public void MathIt()
        {
            // Variables to hold the age value returned from the Calculate method and the string we'll convert it to.
                string ageString;
                int age;

                // Triggers the method for obtaining your age and then converts the result to a string for output.
                BirthdayInformation bdInfo = new BirthdayInformation();
                ageString = bdInfo.GetAge();
                age = Int32.Parse(ageString);
                Console.WriteLine(("You are {0} years old in dog years!"), Calculate(age));
        }
Пример #2
0
        // Reference to interface method
        public void MathIt()
        {
            string ageString;
                int age;
                bool BeforeAfter;
                string year;

                BirthdayInformation bdInfo = new BirthdayInformation();
                ageString = bdInfo.GetAge();
                age = Int32.Parse(ageString);

                BeforeAfter = bdInfo.HaveYouHadYourBirthday();
                if (BeforeAfter)
                {
                    year = CalculateAfter(age);
                }
                else
                    year = CalculateBefore(age);

                Console.WriteLine(("You were born in the year {0}."), year);
        }