示例#1
0
        private IOrder getRandomOrder()
        {
            IOrder order;

            int rndInt = _random.Next(1, 4);

            switch (rndInt)
            {
            case 1:
                order = new Move();
                break;

            case 2:
                order = new Rotate(getDirection());
                break;

            case 3:
                order = new FireTorpedo(getCoordinates(), CoordinateType.Relative);
                break;

            default:
                throw new Exception("not a valid direction");
            }
            return(order);
        }
示例#2
0
        private IOrder Rotate()
        {
            IOrder          order;
            RotateDirection rotate = RotateDirection.Left;

            if (_random.Next(1, 100) > 85)
            {
                rotate = RotateDirection.Right;
            }

            order = new Rotate(rotate);
            return(order);
        }