Just to add to what Miga already mentioned... On Sun, Feb 14, 2010 at 9:22 PM, miga <[email protected]> wrote:
> > > On Feb 14, 1:07 pm, "[email protected]" <[email protected]> wrote: > > Dear All > There are a couple of errors in it. Do you use NetBeans to make your > project? If not, I would first recommend to use it, this way you will > see the errors, before trying to compile it, with tooltip indicating > what needs to be changed. > So: > > 1 - Replace all the parentheses () with square braces when you want to > access a value in an array by index. > For example pinCount[rollIndex + 1] > You might want to read on Java arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html > > 2 - declare pintCount as private static variable in the class, not in > the main method. Something like: > private static int pinCount[] =... > When you declared pinCount inside the main method, the pinCount variable becomes only accessible inside that scope. So when you tried to access pinCount from the other methods, they will tell you that they cannot see that variable. Hence, you have to declare it in the class level. Also, non-static members (variables or methods) cannot be accessed directly from static methods, so you will have to declare it as static like what Miga said. > > 3 - Change the parameter of score method to use the pinCount array, > not a fancy *xxx, and make the method private. Something like: > private int score(int[] pinCount()... > Again, this is a case of knowing the syntax for Java arrays. > > 4 - Change the variable in the for loop to get from 1 to 9 instead of > 0 to 10 > > 5 - Remove pinCount from main method > > 6 - Create a new instance of Scorecard in main, like this: > Scorecard scorecard = new Scorecard(); > > 7 - Invoke correctly the score method in main: > scorecard.score(pinCount); > > 8 - Save all > > 9 - Run again > > By me, it gives: > Total Score is: 240 > > Ask Java experts (which I'm not), if you want a philosophical view of > the why, what, where, etc... of this. > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected]<javaprogrammingwithpassion%[email protected]> > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en > Good luck! -- Randell Benavidez http://randell.ph/ -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
