Exemple #1
0
            public void VisitNextHouse(char direction)
            {
                House nextHouse = null;

                switch (direction)
                {
                case '^':
                    nextHouse = new House(CurrentHouse.X, CurrentHouse.Y + 1);
                    break;

                case 'v':
                    nextHouse = new House(CurrentHouse.X, CurrentHouse.Y - 1);
                    break;

                case '<':
                    nextHouse = new House(CurrentHouse.X - 1, CurrentHouse.Y);
                    break;

                case '>':
                    nextHouse = new House(CurrentHouse.X + 1, CurrentHouse.Y);
                    break;
                }

                if (!Houses.Any(h => h.X == nextHouse.X && h.Y == nextHouse.Y))
                {
                    Houses.Add(nextHouse);
                }

                CurrentHouse = nextHouse;
            }
        public int GetNewNumber()
        {
            var max = 1;

            if (Houses.Any())
            {
                max += Houses.Max(w => w.Nr);
            }

            return(max);
        }
Exemple #3
0
 public bool Contains(string player)
 {
     return(Houses.Any(x => x.PlayerName == player));
 }