-
-
Save IMSoP/90bc1e9e2c56d8314413d7347e76532a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Braces would look like this (give or take a few new lines :P): | |
if (angle <= 30 || angle >= 330) { | |
return Car::EDirection::RIGHT; | |
} else if (angle <= 60) { | |
return Car::EDirection::UP_RIGHT; | |
} else if (angle <= 120) { | |
return Car::EDirection::UP; | |
} else if (angle <= 150) { | |
return Car::EDirection::UP_LEFT; | |
} else if (angle <= 210) { | |
return Car::EDirection::LEFT; | |
} else if (angle <= 240) { | |
return Car::EDirection::DOWN_LEFT; | |
} else if (angle <= 300) { | |
return Car::EDirection::DOWN; | |
} else if (angle <= 330) { | |
return Car::EDirection::DOWN_RIGHT; | |
} | |
// Not this, which would indeed by horrible, but completely unnecessary: | |
if (angle <= 30 || angle >= 330) { | |
return Car::EDirection::RIGHT; | |
} else { | |
if (angle <= 60) { | |
return Car::EDirection::UP_RIGHT; | |
} else { | |
if (angle <= 120) { | |
return Car::EDirection::UP; | |
} else { | |
if (angle <= 150) { | |
return Car::EDirection::UP_LEFT; | |
} else { | |
if (angle <= 210) { | |
return Car::EDirection::LEFT; | |
} else { | |
if (angle <= 240) { | |
return Car::EDirection::DOWN_LEFT; | |
} else { | |
if (angle <= 300) { | |
return Car::EDirection::DOWN; | |
} else { | |
if (angle <= 330) { | |
return Car::EDirection::DOWN_RIGHT; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
// If you didn't use else, you'd have exactly the same braces and nesting as my first example | |
// (but might have different new lines, depending on your agreed style) | |
if (angle <= 30 || angle >= 330) { | |
return Car::EDirection::RIGHT; | |
} | |
if (angle <= 60) { | |
return Car::EDirection::UP_RIGHT; | |
} | |
if (angle <= 120) { | |
return Car::EDirection::UP; | |
} | |
if (angle <= 150) { | |
return Car::EDirection::UP_LEFT; | |
} | |
if (angle <= 210) { | |
return Car::EDirection::LEFT; | |
} | |
if (angle <= 240) { | |
return Car::EDirection::DOWN_LEFT; | |
} | |
if (angle <= 300) { | |
return Car::EDirection::DOWN; | |
} | |
if (angle <= 330) { | |
return Car::EDirection::DOWN_RIGHT; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment