Code debbuging
I'm doing a project, the code is finished, i think, it runs and all, but some of the tests that i had to run with it are giving wrong outputs, and i honestly have no clue about what's wrong... could someone help me with it?
31 Replies
⌛ This post has been reserved for your question.
Hey @Yumi! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
btw i'm using Java without classes yes, stupid university stuff
Everything is a class in Java. Unless it's a primitive.
it's like a preview version of java
without public / static...
show the test and the code that its testing
output file is expected output
and whats the current output
Player P: cell 4, laps 0!
dcbaP.......... (ongoing)
Player P: cell 5, laps 0!
.dcbaP......... (ongoing)
Player P: cell 6, laps 0!
..dcbaP........ (ongoing)
Player P: cell 7, laps 0!
...dcbaP....... (ongoing)
Player P: cell 9, laps 0!
....dcba.P..... (ongoing)
Player P: cell 12, laps 0!
....Sdcba...P.. (ongoing)
Player P: cell 1, laps 0!
.P..S.dcba..... (ongoing)
Player P: cell 5, laps 1!
....SP.dcba.... (ongoing)
Player P: cell 9, laps 1!
....S..dcPba... (ongoing)
Player P: cell 14, laps 1!
....S...dc.ba.P (ongoing)
Player P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
Race ended: P won the race!
Race ended: P won the race!
Race ended: P won the race!
Race ended: P won the race!
....P...dc.ba.. (ended)
Race ended: P won the race!
well looks like its skipping cells
or picking a different path basically
so... any tip on how could i make it go right?
ill check the code tomorrow cuz i need to launch it to check
My time to shine 😜
Am i right that the first file is all the code?
Why is there even a
readTrack or readInput?
Why the input.nextLine(); int the main
Btw, doing all of this with "global" variables is kinda meh in my opinionyess
"guidelines" they gave us at university...
what would u recomend there?
Bruh... change your uni^^
they tell us to do input.nextLine() always to consume the line break, idk
Do the non-final ones with local variables and input parameters... might bloat the code though in other ways... probably there is no perfect solution without classes or at least structs
Ah wait true, i'm just braindead
Why even do all of this in Java, this looks like cracked C (not your fault, i'm lamenting over the didactics your teachers use)
ik it does.. i've coded in C before and it looks too similar 😭
well, in the meantime i was able to fix my problem with the collisions, that was.. doubtufull
This message has been formatted automatically. You can disable this using
/preferences.This is sus:
Why do you just
return getPosition(targetPosition - 1);? How do you know, that the next position behind is free
Lol, you where one second faster
Still errors popping up?there is a very fun error, in a code part that should run fine, the car just decides to do +1 speed on his own, and return to normal behaviour, but with +1 in position...
that was the point, i didn't know, and there was a big chance it wasn't free
I know, this is why i wrote this https://discord.com/channels/648956210850299986/1432037931798761472/1432102423731900417 xD
Show
Maybe this is the cause, wild guess
amen, lol
I have to proof read a friend's bachelor's thesis now, i will help later if you still need
no, ig i'm done with the project.. it was due 8pm.. but as hour changed, it gave us an extra hour, lol
but i'll just accept my 97% on the code function
still, thank you very much
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Hmmm, wait
How long till you have to put it in in minutes?
@Yumi
24
Okay, we got this
good luck to your friend 🫡
thx
Post Closed
This post has been closed by <@1348700887161245751>.