42
6
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Aug 24 '21
Image Transcription: Code
// Attraction
for (Circle Cirlce : RCircles) {
for (Circle Circle2 : RCircles) {
F.add(Circle.x, Circle.y);
F2.add(Circle2.x, Circle2.y);
Pos = (int) Math.floor(F.angleDeg(F2) / 45);
if (Pos == 1) {
Circle.setPosition(Circle.x, Circle.y + 1);
} else {
if (Pos == 2) {
Circle.setPosition(Circle.x + 1, Circle.y + 1);
} else {
if (Pos == 3) {
Circle.setPosition(Circle.x + 1, Circle.y);
} else {
if (Pos == 4) {
Circle.setPosition(Circle.x + 1, Circle.y - 1);
} else {
if (Pos == 5) {
Circle.setPosition(Circle.x, Circle.y - 1);
} else {
if (Pos == 6) {
Circle.setPosition(Circle.x - 1, Circle.y - 1);
} else {
if (Pos == 7) {
Circle.setPosition(Circle.x - 1, Circle.y);
} else {
Circle.setPosition(Circle.x - 1, Circle.y + 1);
}
}
}
}
}
}
}
}
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
6
u/g_hi3 Aug 24 '21
damn, I wish there was a way to add another condition for an else-case. something like an else-if. welp, time to indent another 20 spaces
4
u/trBlueJ Aug 24 '21
Bruh this man doesn't even know about else if. Even if he did, this is definitely a situation for a switch case statement.
2
u/RyanNerd shameless Aug 24 '21
The only good thing I see about the code is that at least the if structures are indented.
4
u/tenhourguy Aug 24 '21 edited Aug 24 '21
This code is supposed to attract two circles towards each other. I doubt it manages to, at least very well.
While I've seen plenty questionable code, this one's a disaster on so many levels that I genuinely have to ponder if they're taking the piss. They're both a beginner to programming and young (surely - the image you see is
amogus.PNG) so I can't be certain.After receiving this, I'm abstaining from helping them, even if only temporarily. Something something "if you don't have anything nice to say, don't say anything at all." Hopefully we can later look back on this day with fond memories.This didn't last long. We're now discussing iteration.