public void MoveShip(IKapitein captain) { Location from = Ship.GetLocation(); Location to = GetNewLocation(from, captain); if (IsNewLocationValid(to, Ship)) { Ship.SetLocation(to); } }
private Location GetNewLocation(Location from, IKapitein captain) { var direction = captain.GetDirection(); if (ShouldTurn(direction, from)) { return(GetNewLocationByTurning(direction, from)); } return(GetNewLocationByMoving(direction, from)); }
public void Navigate() { var assestprovider = new BattleshipAssestProvider(Ship); IKapitein captain = assestprovider .GetCaptains() .FirstOrDefault(); bool hasCaptain = captain != null; if (hasCaptain && captain.ShouldMove()) { MoveShip(captain); } }