Exemple #1
0
            static void Main(string[] args)
            {
                //Add Areas
                Area a = new Area("A", "");
                Area b = new Area("B", "");
                Area c = new Area("C", "");
                Area d = new Area("D", "");

                //connect Areasto each other
                a.AddArea(c, Directions.West);
                c.AddArea(a, Directions.East);
                c.AddArea(d, Directions.West);
                d.AddArea(c, Directions.East);
                a.AddArea(b, Directions.North);
                b.AddArea(a, Directions.South);

                //Where do you start
                Area currentArea = a;

                //Read input in console
                string Command = Console.ReadLine();

                //split the command into pieces
                string[] inputs = Command.Split(' ');
                //looks ar the first word in the command and sees if it is a command
                switch (inputs[0])
                {
                //if "go" command is given
                case "go":
                case "Go":
                    switch (inputs[1])
                    {
                    case "east":
                    case "East":
                        GoToDirection(Directions.East, ref currentArea);
                        break;

                    case "west":
                    case "West":
                        GoToDirection(Directions.West, ref currentArea);
                        break;

                    case "north":
                    case "North":
                        GoToDirection(Directions.North, ref currentArea);
                        break;

                    case "south":
                    case "South":
                        GoToDirection(Directions.South, ref currentArea);
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
Exemple #2
0
        public void AddAreaTest(Directions dir)
        {
            Area a = new Area("The basement", "it's locked and damp");
            Area b = new Area("The crypt", "The tombs have already been raided :(");

            //defining edges
            a.AddArea(b, dir);

            Assert.AreEqual(a.neighbors[dir], b);
        }