Exemplo n.º 1
0
        public static void Run()
        {
            string exit = "a";

            while (exit != "q")
            {
                Child[] kidArray     = new Child[0];
                Adult[] adultArray   = new Adult[0];
                int     adultEntries = 0;
                int     kidEntries   = 0;
                Commands();
                string userInput = Console.ReadLine();
                if (userInput == "exit" || userInput == "quit")
                {
                    exit = "q";
                }

                if (userInput == "add")
                {
                    Console.Write("Name? ");
                    string userName = Console.ReadLine();
                    Console.Write("Age? ");
                    int userAge = Int16.Parse(Console.ReadLine());

                    if (userAge < 18)
                    {
                        Console.Write("Favourite bike? ");
                        string userBike  = Console.ReadLine();
                        Child  underAged = new Child(userName, userAge, userBike);
                        kidEntries++;
                        Array.Resize(ref kidArray, kidEntries);
                        kidArray[kidEntries - 1] = underAged;
                    }
                    else if (userAge > 17)
                    {
                        Console.Write("Favourite car? ");
                        string userCar   = Console.ReadLine();
                        Adult  legalAged = new Adult(userName, userAge, userCar);
                        adultEntries++;
                        Array.Resize(ref adultArray, adultEntries);
                        adultArray[adultEntries - 1] = legalAged;
                    }
                }
                // if (userInput == "lc")
                // {
                //     for (int i=0; i<kidEntries; i++)
                //     {
                //         Child kiddo = kidArray[i];
                //         Console.WriteLine(kiddo);
                //     }
                // }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            People.Greeting();
            People.Run();


            Child kid = new Child("Troy", 14, "Trekker");

            kid.ChildPrint();
            Child kido = new Child();

            kido.ChildPrint();

            Adult man = new Adult();

            man.AdultPrint();
        }