示例#1
0
        private static void GenerateAndPrintCouple(God god)
        {
            IHasName human1 = god.CreateHuman();
            IHasName human2 = god.CreateHuman();

            human1.ToConsole();
            human2.ToConsole();

            try
            {
                IHasName result = god.MakeCouple((Human)human1, (Human)human2);
                if (result == null)
                {
                    Console.WriteLine("They didn't like each other");
                }
                else
                {
                    result.ToConsole();
                }
            }
            catch (WrongCoupleException)
            {
                Console.WriteLine("Wrong couple");
            }
        }
示例#2
0
        private static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine(Resources.About);
            if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                Console.WriteLine(Resources.SundayGreeting);
                return;
            }

            Console.WriteLine(Resources.WorkDayGreeting);
            Console.WriteLine(Resources.HowToUse);

            var        entitiesGenerator = new EntitiesGenerator();
            ConsoleKey pressedKey;

            do
            {
                Human parent        = entitiesGenerator.CreateRandomHuman();
                Human anotherParent = entitiesGenerator.CreateRandomHuman();
                parent.ToConsole();
                anotherParent.ToConsole();
                try
                {
                    IHasName child = entitiesGenerator.Couple(parent, anotherParent);
                    if (child == null)
                    {
                        Console.WriteLine(Resources.FailedCoupleCreation);
                    }
                    else
                    {
                        child.ToConsole();
                    }
                }
                catch (SameSexException exception)
                {
                    Console.WriteLine(exception.Message);
                }
                Console.WriteLine();
                pressedKey = ReadControlKey();
            } while (!IsInterruptKey(pressedKey));
        }