Remember, Strings are immutable. That means they can never change. The replace method returns another String that is the result of replacing characters in the String that you called the replace method on. In other words, when you call pgr.replace(...), pgr does not change. You have to assign the result of replace() to something.
Another suggestion, while you're taking them: Try to give better variable names. When someone reads your code, do the names "x", "y", "pgr" help them make any sense of what's happening? It's like reading a sentence that goes something like this: "One dy, our grdnr, Bthlmw, dcded he wntd to mrry our tchr, Miss Lsbth." --- this is kind of hard to understand, right? Your code should tell the reader a story of what's happening. Well-written code is about telling people what's going on. The computer could care less because it knows what to do regardless of what name you give.
Your code reads a lot better and I can actually make out the "story" you are trying to tell here. Now, like any good composition, it needs to be broken down into smaller chunks, like paragraphs and chapters and parts. See how you have everything in main()? This is where most people start but soon you'll learn that main() should only be like the preface of a story. The "meat" of the code should be in full-fledged objects, and different sections of the code should be assigned to different objects, each with their own responsibility. Not saying you have to do it now. You'll eventually realize this as you learn more about different object-oriented programming concepts. Good job and good luck!
Joined: Aug 10, 2012
Hi people, well Junilu - your wish is my command. I have had a go. Good news, compiles and runs - Bad news I think it's a little messy. Especially with the way I create the player object into the arraystore class and then having to "double reference" my objects in main (e.g as.p.playerguess). Any thoughts or concepts I am missing to tidy up even further?