Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Final program in Java help
#1
[COLOR="Red"]Last assignment of the semester and by far the hardest, can you guys help me out with it?

In one part, i want to create an array of cheaters and output it, but i can't seem to figure it out:
http://pastie.org/733042

The second part I want to output the other vehicles in the order in which they came in a race, minus the first place person:
http://pastie.org/733044

Any help would be great guys.[/COLOR]
Reply
#2
Those single letter variable names and awkward indentation make it kind of hard to figure out what you're trying to do here Hurt
Reply
#3
Russt Wrote:Those single letter variable names and awkward indentation make it kind of hard to figure out what you're trying to do here Hurt

This. You'll want to name your variables and whatnot so that they describe what they do, or at least give a sense of what they're suppose to be. If you keep on programming long enough, somewhere down the road, you'll really wish you had done this if you return to old code. It's almost like composing nerd poetry at times xD

At the same time though don't make the names too long. That's also bad and it causes clutter.


These comments are irrespective of who wrote what, since I can't really tell >_>

--Wth is array1[]? Being generically named and also never seeing it declared (unless I'm blind) doesn't tell me what it's suppose to be. It seems like it's a racer object that has a flag and SSN field at least?
--for (int b=0; b<=array1.length-1 ; b++){ ... } = for (int b=0; b<array1.length ; b++){ ... }. It's negligible, but I know some people that would yell at you for doing unnecessary operations.
--Apparently as the first while loop is set up, if a cheater is found, it sets off an infinite loop sequence, since boolean a is false, and countV will never increment. Speaking of boolean a, you can just say if(a) instead of if(a==true) and it should be okay.
--The two for loops that sort out winners and losers, you could do it with one run through instead of two and decide whether the person in question is a winner or loser. If he isn't a winner, he must be a loser right?

Whole code for part 1 is kinda vague to me. Why not just use a systematic SSN matching procedure instead of an RNG and then use a for loop to print out the list of cheaters?

Ignoring all the crap I don't understand in part 2, the only thing you did wrong for outputting the other racers is that you're always printing "\n\nThese are the cars that arrived after the winner was declared in sequential order: ". You should put that message outside of the loop instead so you only have to see it once.
Reply
#4
[COLOR="Red"]Ah, okay, I see.

This was a group project and my partner and I had two different codes. Mine actually did have descriptive variable names. The only reason we went with his code is that he had a StringTokenizer in his code and the TA decided to work with his code, not mine. I for one did not want to go back and redo all his variables.

I should have made that more clear, sorry.

After reading what you guys have said, I have made the necessary changes.
Thanks.[/COLOR]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)