Пример #1
0
        private static void DoAbstractFactory()
        {
            AnimalWorld animalWorld = new AnimalWorld(new EuropaContinent());

            animalWorld.ExecuteFoodChain();
            Console.ReadKey();
        }
Пример #2
0
        public void FirstTest()
        {
            ContinentFactory africa = new AfricaFactory();
            var world = new AnimalWorld(africa);
            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();
            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
Пример #3
0
        static void Main(string[] args)
        {
            ContinentFactory myContinentFactory = new AfricaFactory();
            AnimalWorld      myAnimalWorld      = new AnimalWorld(myContinentFactory);

            myAnimalWorld.RunFoodChain();

            myContinentFactory = new AmericaFactory();
            myAnimalWorld      = new AnimalWorld(myContinentFactory);
            myAnimalWorld.RunFoodChain();
        }
Пример #4
0
        static void Main(string[] args)
        {
            AnimalWorld world = new AnimalWorld(new AfricaFactory());

            world.RunFoodChain();
            Console.WriteLine("===================");
            world = new AnimalWorld(new AmericaFactory());
            world.RunFoodChain();

            Console.ReadKey();
        }
        public void Execute()
        {
            ContinentFactory afrika = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(afrika);

            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
Пример #6
0
        public static void TestContinentFactory()
        {
            ContinentFactory africa = new AfricaFactory();
            var world = new AnimalWorld(africa);

            StringAssert.AreEqualIgnoringCase("Lion eats Wildebeest", world.RunFoodChain(true));

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            StringAssert.AreEqualIgnoringCase("Wolf eats Bison", world.RunFoodChain(true));
        }
Пример #7
0
        public static void RunRealWorldExample()
        {
            ContinentFactory americanFactory = new AmericanFactory();
            var americanAnimalWorld          = new AnimalWorld(americanFactory);

            americanAnimalWorld.DescribeAnimalBehavior();

            ContinentFactory asianFactory = new AsianFactory();
            var asianAnimalWorld          = new AnimalWorld(asianFactory);

            asianAnimalWorld.DescribeAnimalBehavior();
        }
Пример #8
0
        public void AbstractFactoryTest()
        {
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(africa);

            Assert.IsTrue(world.RunFoodChain() == "Lion eats Wildebeast");

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            Assert.IsTrue(world.RunFoodChain() == "Wolf eats Bison");
        }
Пример #9
0
        private static void AbstractFactoryDemo()
        {
            var africa = new AfricaFactory();
            var world  = new AnimalWorld(africa);

            world.RunFoodChain();

            var america = new AmericaFactory();

            world = new AnimalWorld(america);

            world.RunFoodChain();
        }
Пример #10
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public void Run()
        {
            // Create and run the African animal world
            var africa = new AfricaFactory();
            var world  = new AnimalWorld(africa);

            world.RunFoodChain();

            // Create and run the American animal world
            var america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
Пример #11
0
    // Entry point into console application.
    public static void Main()
    {
        // Create and run the African animal world
        continent = new AfricaFactory();
        fauna     = new AnimalWorld(continent);
        fauna.RunFoodChain();

        // Create and run the American animal world
        continent = new AmericaFactory();
        fauna     = new AnimalWorld(continent);
        fauna.RunFoodChain();

        // Wait for user input
        Console.ReadKey();
    }
Пример #12
0
        public static void Main(string[] args)
        {
            //Create and run the African animal world
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld world = new AnimalWorld(africa);
            world.RunFoodChain();

            // Create and run the American animal world
            ContinentFactory amercia = new AmericaFactory();
            world = new AnimalWorld(amercia);
            world.RunFoodChain();

            //wait for user input before closing application
            Console.ReadKey(true);
        }
Пример #13
0
        private static void TestFactory()
        {
            Console.WriteLine("Testing factory...");
            // Create and run the African animal world
            ContinentFactory africa = new AfricaFactory();
            var world = new AnimalWorld(africa);

            world.RunFoodChain();

            // Create and run the American animal world
            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
        public void MainTest()
        {
            // TODO
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(africa);

            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();

            Assert.AreEqual(1, 1);
        }
        public static void Main(string[] args)
        {
            ForegroundColor = ConsoleColor.Cyan;
            const string dateTimeFormat = @"MM / dd / yyyy HH: mm: ss.fff";

            var len = 2;
            var d = 9;
            WriteLine($"{(((len%9)*(d%9))%9)}");


            WriteLine("Start -> {0}\n", DateTime.Now.ToString(dateTimeFormat, CultureInfo.InvariantCulture));

            var africaAnimals = new AnimalWorld<AfricanAminals>();
            africaAnimals.RunFoodChain();

            var americalAnimals = new AnimalWorld<AmericanAnimals>();
            americalAnimals.RunFoodChain();

            WriteLine("\nEnd -> {0}", DateTime.Now.ToString(dateTimeFormat, CultureInfo.InvariantCulture));
            WriteLine("\n\nPress any key ....");
            ReadKey();
        }
    // Entry point into console application.
    public static void Main()
    {
        // Create and run the African animal world
        continent = new AfricaFactory();
        fauna = new AnimalWorld(continent);
        fauna.RunFoodChain();

        // Create and run the American animal world
        continent = new AmericaFactory();
        fauna = new AnimalWorld(continent);
        fauna.RunFoodChain();

        // Wait for user input
        Console.ReadKey();
    }
Пример #17
0
  public static void Main( string[] args )
  {
    // Create and run the Africa animal world
    ContinentFactory africa = new AfricaFactory();
    AnimalWorld world = new AnimalWorld( africa );
    world.RunFoodChain();

    // Create and run the America animal world
    ContinentFactory america = new AmericaFactory();
    world = new AnimalWorld( america );
    world.RunFoodChain();

    Console.Read();
  }
Пример #18
0
 public static void RunMain()
 {
     ContinentFactory americanFactory = new AmericanAnimalFactory();
     ContinentFactory africanFactory = new AfricanAnimalFactory();
     AnimalWorld world = new AnimalWorld(americanFactory);
     world.Run();
     AnimalWorld world1 = new AnimalWorld(africanFactory);
     world1.Run();
 }