コード例 #1
0
 public void Move()
 {
     Console.WriteLine("{0} is moving from {1}, {2}", _name, _xCoordinate, _yCoordinate);
     Console.Write("{0} is moving by ", _name);
     _moveBehavior.Move();
     _xCoordinate += _xVelocity;
     _yCoordinate += _yVelocity;
     Console.WriteLine("{0} is now at {1}, {2}", _name, _xCoordinate, _yCoordinate);
 }
コード例 #2
0
        [HttpPost("{_}/move")] // Для универсальности ¯\_(ツ)_/¯
        public virtual IActionResult Move([FromBody] MoveDto move)
        {
            try
            {
                var startTime = DateTime.Now;
                var result    = _behavior.Move(MoveDto.MapFromDto(move));

                var diffMilliseconds = (DateTime.Now - startTime).Milliseconds;
                if (diffMilliseconds > 200)
                {
                    Console.WriteLine($"!!!!!!! Вычисление заняло {diffMilliseconds}");
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Ошибка при вызове Move => {ex.Message}");
                return(Ok());
            }
        }
コード例 #3
0
 public void Move()
 {
     moveBehavior.Move();
 }
コード例 #4
0
 public virtual void DoMove()
 {
     MoveBehavior.Move();
 }
コード例 #5
0
 public void StartMoving()
 {
     _moveStrategy.Move(this);
     Console.WriteLine();
     Console.WriteLine($"Position: {Position}");
 }