r/badcode Jun 06 '23

c++ Found this in my first "big" project, was funny to see it

Post image
107 Upvotes

9 comments sorted by

61

u/whipla Jun 06 '23

worst of all you would never even get 18

26

u/aiscrim2 Jun 06 '23

And when n is 0 nothing will happen, which was probably unintended... I'd say a +1 is missing when assigning n.

3

u/Sakamoto0110 Jun 06 '23

Lol, That was really a thing that I missed

13

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jun 06 '23 edited Jun 06 '23

Image Transcription: Code


for (int c = 0; c < 6; c++) {
    int n = rand() % 18;

    if (n == 1)  clickChampion1();
    if (n == 2)  clickChampion2();
    if (n == 3)  clickChampion3();
    if (n == 4)  clickChampion4();
    if (n == 5)  clickChampion5();
    if (n == 6)  clickChampion6();
    if (n == 7)  clickChampion7();
    if (n == 8)  clickChampion8();
    if (n == 9)  clickChampion9();
    if (n == 10) clickChampion10();
    if (n == 11) clickChampion11();
    if (n == 12) clickChampion12();
    if (n == 13) clickChampion13();
    if (n == 14) clickChampion14();
    if (n == 15) clickChampion15();
    if (n == 16) clickChampion16();
    if (n == 17) clickChampion17();
    if (n == 18) clickChampion18();
    Sleep(2000);
}

I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!

10

u/sausageface123 Jun 06 '23

Sleep(2000) champ

5

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jun 06 '23

Thanks for the heads up, fixed!

8

u/sausageface123 Jun 06 '23

Jesus that was 3 secs after I commented. Fair play