Campbell Ritchie wrote:Even though Winston Gutkowski will disagree, you should never use == false or == true or similar. It’s not while (b == false) ..., but while (!b) ...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Or don’t realise how easy it is to get into bad (non-object-oriented) habits at the beginning, and how hard it is to break those bad habits.Joe Vahabzadeh wrote:I'm going to guess that the reason it's a big single method is because this is an introductory class, and maybe they haven't gotten to moving more into object-oriented code yet? . . .
Dennis Deems wrote:To his excellent suggestions, let me add that you might consider giving the enum a String "display" field, which would be very useful in condensing all those repetitive system out statements.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:@Venny: As Campbell says, I disagree with him on this point: x == false and !x are logically equivalent, and unless you think he might be vetting your code, I'd use whatever construct seems clearest to you. Just be sure to use '==' and not '='.
Venny Tank wrote:And my question now is: May I use a "while" loop with two conditional statements like the code above?
Joseph Tulowiecki wrote:You would have to use while ( (userWins < 2) && (compWins <2)){
instead of ||
when you use " || " your saying .. Continue looping as long as either the user has less than 2 wins or the comp has less than 2 wins. This will never stop looping because it is Always true. If the computer has two twins then user has 0 wins and vice versa so one of them will always have less than 2. Therefore the loop will never end. If you use && which means "and" it will give you the results your looking for.
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|