Esempio n. 1
0
        public string MoveTo(Enum direction)
        {
            Location temp = new Location(_point);       //copy contstructor, creates a temp object

            switch (direction)
            {
            case Map.Direction.north:
                temp._y++;
                break;

            case Map.Direction.south:
                temp._y--;
                break;

            case Map.Direction.east:
                temp._x++;
                break;

            case Map.Direction.west:
                temp._x--;
                break;

                //add default case
            }

            if (Map.OnMap(temp))
            {
                _point = temp;
            }

            return("X= " + _point._x + ", Y= " + _point._y);
        }