Exemplo n.º 1
0
        public void AddBattleShip(string position)
        {
            position = position.Trim().ToUpper();
            PositionRange range = new PositionRange(Position.Convert(position), Position.Convert(position));

            AddBattleShip(new BattleShip(range, position));
        }
Exemplo n.º 2
0
        public void AddBattleShip(string start, string end)
        {
            start = start.Trim().ToUpper();
            end   = end.Trim().ToUpper();
            //
            PositionRange range = new PositionRange(Position.Convert(start), Position.Convert(end));

            AddBattleShip(new BattleShip(range, string.Format("{0}->{1}", start, end)));
        }
Exemplo n.º 3
0
 public BattleShip(PositionRange range, string name)
 {
     Positions = new List <Position>();
     Name      = name;
     _range    = range;
     if (_range.Start.X == _range.End.X)
     {
         for (short i = _range.Start.Y; i <= _range.End.Y; i++)
         {
             Positions.Add(new Position(_range.Start.X, i));
         }
     }
     else if (_range.Start.Y == _range.End.Y)
     {
         for (short i = _range.Start.X; i <= _range.End.X; i++)
         {
             Positions.Add(new Position(i, _range.Start.Y));
         }
     }
 }