Gadget wrote:
Pardon my French, but that is some fugly code... you wouldn't want me for a TA! =)
This is a personal project, my school is to small to have a CS class.
Gadget wrote:
4) "Part of the reason for the mess of code is that I don't want any repeats in the pattern."
Repeats in what pattern? Is codeGen supposed to return four different colors?
Yes. codeGen is supposed to return 4 different colors, no repeats.
Gadget wrote:
2) Why do you keep doing this?
if (Array.IndexOf(code, colors.Purple) == -1)
It will set the element in code[] and increment i only if the chosen color is not already in the code[]. Array.IndexOf returns -1 if the second augment is not found in the array, otherwise, it returns the index of the first occurrence.
Gadget wrote:
1) For starters, you should put the i++ in the for loop conditional (ie for (int i = 0; i < 4; i++) { case ... }
I don't see how I can without either
a) putting back in the goto statements, or
b) altering the behavior of the code.
Gadget wrote:
3) "<snip> random function can result in it repeatedly returning the same number <snip>"
This should occur occasionally. Why do you think that your thread change the behavior of the random number generator?
Yes, occasionally a random function should return the previous result again, but if you call the function to quickly, it will return the same value until you give it a break. quick, repeated calls could result in it returning
Code:
6,6,6,6,6,6,6...
That code is just me being excessively cautious while debugging. It will be removed.
Gadget wrote:
5) In terms of the design, you should create two methods: codeGen and colorGen. codeGen calls colorGen 4 times... or randomColor. See below.
Couldn't hurt. At this point I'm just happy it works, although I am open to suggestions for improving it. Thanks for your help!