I have the game running fine but I wish to add History to each completed guess as above. I have a GameHistory Class were I send the users guess to be added to the ArrayList "numberHistory" from the Game Class as shown below. I then want to send each Int array in a loop while less than size() to the "DisplayOutPut" Class for display after each completed incorrect guess. I have no idea how to retrieve each array from the ArrayList to send from "GameHistory" Class to "OutPutDisplay" Class, or if I should collect all three Arrays int [] "guessCode", String[] "textGuess and char[] "feedBack" in seperate ArrayLists , or 1 Oject ArrayList containing the three Arrays or just reprocess int [] "guessCode" to generate the other 2 Arrays again.

I have been looking at this so long I cant get it. I have no idea how to "SSCCE" this as this is the first java oop program I have written with multiple classes.

That is not how you use the code tags- they're square brackets, not < >.

If you want help, you should provide an SSCCE that demonstrates the problem without any extra pieces such as game logic. Nobody wants to download a .rar from a third party site. Make it easy for people to help you!

I'm still not sure what your actual question is. Are you getting errors? Some strange behavior? Something else?

03-15-2012, 08:11 PM

PeteW44

Re: ArrayList of Integer Arrays

I have Amended myself in the hope I am clearer

Cheers

Pete

03-15-2012, 08:25 PM

KevinWorkman

Re: ArrayList of Integer Arrays

I fixed your code tags for you. But I didn't mean that you should just link to something other than a .rar, I meant that all code you want us to look at should be posted in the form of an SSCCE. It should be easy for us to copy and paste the code into an editor so that we can see the problem ourselves.

Sorry, but I'm still not sure what your actual question is. You've listed some requirements and some code, but I'm not sure where you're stuck? Are you getting an error? Strange behavior? Something else? Have you narrowed the problem down at all?

03-15-2012, 08:33 PM

PeteW44

Re: ArrayList of Integer Arrays

I have no idea how to continue.... No errors as nothing really to compile.
I add int [] "guessCode" Array to ArrayList "numberHistory" in a loop up to 12 times = game over. If user guess is incorrect I want to display all previous guesses in the display format above but I dont know how to get the int [] "guessCode" Array out of the ArrayList "numberHistory" to send to other Classes for processing.

I also dont know if I should collect String[] "textGuess and char[] "feedBack" Arrays in seperate ArrayLists , or 1 Oject ArrayList containing all three Arrays or just reprocess int [] "guessCode" through other Class Methods to generate the other 2 Arrays again.

I will try agin later if I am still confusing.

Cheers

Pete

03-15-2012, 08:38 PM

KevinWorkman

Re: ArrayList of Integer Arrays

The best I can tell you is to break your problem up into smaller pieces. Each piece roughly translates to a single method that might take a parameter and might return a value. For example, one method would prompt the user for input and then convert that input to the appropriate data type and return it. That's one piece. Get that piece working perfectly before you move onto the next piece. The next piece might take a data type and do some kind of calculation with it- get that piece working perfectly, and then try to use the first piece to feed into the second piece (so the first piece would take user input and return a data type, which you could then pass into the second piece to perform the calculation). Repeat that process until you've finished your program. And when you get stuck, you can post just that single piece instead of your whole program, which will make it easier for us to help you. Good luck!

03-15-2012, 11:40 PM

PeteW44

Re: ArrayList of Integer Arrays

I have the game working as is,

1. I dont know how to get the "guessCode" int[] Arrays out of the ArrayList so I can send them to another class for either display or further processing?

2. I dont know if I should collect all three Arrays and if so should they be seperate ArrayLists or a single ArrayList containing all three Arrays Int[], String[] and char[]. I have methods in other classes that I can send the userGuess int[] Array to Convert to create a new String[] Array which describes the colours in text and also create and organise the FeedBack char[] Array.

As I am unable to articulate my issue I have attempted to write code from my GuessHistroy Class. I intend to call this method after every guess so I can give a quick refresh of the users previous guesses, I have add methods adding the int [] "guessCode" Array to ArrayList "numberHistory" and the char[] "feedBack" Array to ArrayList "feedBackHistory" I am just going to regenerate the String[] "textGuess" Array reusing its display method.

As you can notice I highlighted in red the issue I think! I want to pass the Arrays stored in the ArrayLists onto another Method in another Class for display. I dont know how to say "get the Array from this ArrayList in the position "gameLoop" and send in on please, thankyou. Ohhh and also do this again until its done as many times as the ArrayLists are long".

Sorry for being so SO but I am not understanding java ArrayLists and how to get the added Arrays OUT and Passed on. I would be most appreciative of some assistance as I am pickled, so far this coursework has taken many many days working 10am til 4am.