Esempio n. 1
0
        static void Main(string[] args)
        {
            Person p1 = new Person();

            Console.WriteLine("What is your First Name?");
            p1.FirstName = Console.ReadLine();
            Console.WriteLine("What is your Last Name?");
            p1.LastName = Console.ReadLine();
            Console.WriteLine("What is your age?");
            p1.Age    = int.Parse(Console.ReadLine());
            p1.Spouse = new Person();

            Person.SumofAllAges = Person.SumofAllAges + p1.Age;

            p1.PrintNameAndAge();

            Console.WriteLine("What is your Spouse's Name?");
            p1.Spouse.FirstName = Console.ReadLine();
            p1.Spouse.LastName  = p1.LastName;
            Console.WriteLine("What is your Spouse's Age?");
            p1.Spouse.Age    = int.Parse(Console.ReadLine());
            p1.Spouse.Spouse = p1;

            Person.SumofAllAges = Person.SumofAllAges + p1.Spouse.Age;

            p1.Spouse.PrintNameAndAge();

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();

            Person p2 = new Person();

            Console.WriteLine("What is your First Name?");
            p2.FirstName = Console.ReadLine();
            Console.WriteLine("What is your Last Name?");
            p2.LastName = Console.ReadLine();
            Console.WriteLine("What is your age?");
            p2.Age    = int.Parse(Console.ReadLine());
            p2.Spouse = new Person();

            Person.SumofAllAges = Person.SumofAllAges + p2.Age;

            p2.PrintNameAndAge();

            Console.WriteLine("What is your Spouse's Name?");
            p2.Spouse.FirstName = Console.ReadLine();
            p2.Spouse.LastName  = p2.LastName;
            Console.WriteLine("What is your Spouse's Age?");
            p2.Spouse.Age    = int.Parse(Console.ReadLine());
            p2.Spouse.Spouse = p2;

            Person.SumofAllAges = Person.SumofAllAges + p2.Spouse.Age;

            p2.Spouse.PrintNameAndAge();

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Person P1 = new Person();
            Person P2 = new Person();

            P1.GetAnswers();
            Console.WriteLine();
            P2.GetAnswers();

            Console.WriteLine();
            P1.PrintNameAndAge();
            P2.PrintNameAndAge();
            P1.Spouse.PrintNameAndAge();
            P2.Spouse.PrintNameAndAge();
            Console.WriteLine();
            Console.WriteLine("Average Age of All " + Person.Count + " People: " + Person.AvgAge());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {

            Person p1 = new Person();
            Person p2 = new Person();

            p1.CollectData("p1");      
            p1.CollectDataSpouse();                 
            p2.CollectData("p2");                                  
            p2.CollectDataSpouse();

            Utilities.printHeader();
            
            p1.PrintNameAndAge();
            if (p1.Spouse != null) { p1.Spouse.PrintNameAndAge(); }            
            p2.PrintNameAndAge();
            if (p2.Spouse != null) { p2.Spouse.PrintNameAndAge(); }

            System.Console.WriteLine("");
            System.Console.WriteLine("Average Age: " + Person.GetAverageAge());                            
            System.Console.ReadKey();

        }