Esempio n. 1
0
        public static void Main(string[] args)
        {
            System.Console.CursorVisible = false;

            const int rows = 20;
            const int columns = 20;
            var savannah = new Savannah(rows, columns);
            var game = new Game(savannah);
            var visitor = new ConsoleVisitor();

            while (true)
            {
                IEnumerable<Action> actions = game.Tick();

                foreach (Action action in actions)
                {
                    action();
                }

                System.Console.Clear();
                game.Accept((ISavannahVisitor) visitor);
                game.Accept((IAnimalVisitor) visitor);
                Thread.Sleep(TimeSpan.FromMilliseconds(500));
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            IVisitor       console   = new ConsoleVisitor();
            CounterVisitor counter   = new CounterVisitor();
            IRoom          kitchen   = new Kitchen();
            IRoom          bathroom  = new Bathroom();
            IRoom          apartment = new Apartment();

            kitchen.Accept(counter);
            bathroom.Accept(console);
            apartment.Accept(counter);

            console.Visit((Kitchen)kitchen);
            counter.PublishCounter();
        }
Esempio n. 3
0
        public void TestVisitTimePeriodsInReverseOrder()
        {
            // Arrange
            TestSource source   = new TestSource();
            Timeline   timeline = new Timeline();

            timeline.AddTimeSource(source);
            timeline.Build();
            ConsoleVisitor visitor = new ConsoleVisitor();

            // Act
            timeline.VisitTimePeriodsInReverseOrder(visitor);

            // Assert
            Assert.AreEqual(2, timeline.TimePeriods.Count);
        }