The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Simon game, still not working 2 months in.

Working on simon says game in java. Program compiles fine, but when playing game, gameplay is not working as intended. I've been trying to find the problem for more than two weeks, but I can't find it. I've added code to the program to print to the console when the problematic parts of the program are running. I have done everything I know to do, and I'm really frustrated. Can someone PLEASE take a look, and see if they can help me? I put the entire program so that you can run it yourselves while looking.

Re: Simon game, still not working 2 months in.

"not working" is not a helpful description of the problem. What exactly is happening? What should be happening? Can you provide us with the output log?

NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.

Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Re: Simon game, still not working 2 months in.

It's supposed to start by generating a random color, adding to pattern and then showing the pattern before passing control to the player. It (seems) to do this fine. The player then makes a move, but it appears the function to check input ends up running twice at this point, and the game does not continue.

I know I'm not explaining it well, but It will make plenty more sense if you throw the code into a file and run it. Really tired, so sorry if some answers are incoherent or leave out key stuff, I will answer any questions in an attempt to get this working.

Re: Simon game, still not working 2 months in.

I'm going to take a shot in the dark and assume what you are really doing here is not what you intend to do:

if(pattern.get(iterator)=="Green")

Compare Strings with .equals() not ==

if(pattern.get(iterator).equals("Green"))

Change that on all of your if statements, and tell me if anything changes.

EDIT:
Also, the final else statement in this section is unreachable (meaning you don't need it, because you can never get there):

if(isPlayerTurn ==true){
playerTurn();}elseif(isPlayerTurn ==false){
simonTurn();}else// <----- You don't need this else block, isPlayerTurn can only be true or false{System.out.println("Error: Player turn has not been assigned,"+" or has value other than a boolean.");}

NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.

Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Re: Simon game, still not working 2 months in.

Now, its working better. It is now showing the pattern, but it is not pausing in between flashing each button, (all are just flashing at once), and I have code that should handle that, but apparently it isn't. Also, highScore and currentScore displays are not updating.

Re: Simon game, still not working 2 months in.

Sorry, again, tired, so if I'm a little impatient, I apologize. My thoughts on the score displays, I have no idea. It should be working. On the timing, I know I need to implement some kind of method that delays it, but I'm not sure how to best do it.