return direction;
return directionD;
You cannot have two return statements like this without a condition. When the first return statement is executed, there is no chance to reach the second return statement. That's why there is an unreachable statement.