By my understanding, variables with default access modifiers are supposed to be able to be accessed from anywhere in a package, and if I'm not mistaken, a package means a single file? Or, does a package mean literally, only if it's named as a package at the top of the file?
The problem is my booleans on line 10. I'm trying to reuse the same boolean variables in my score class and in my main method. But the compile is returning "cannot find symbol" errors for every attempt to use them in my main method.
// an easy to use program to hold snooker match scores and feed detailed statistics to the user import java.util.Scanner; // class Score _ returns points for pots and fouls class Score{ final private int[] value = {1,2,3,4,5,6,7}; // array of values for ball colour int reds = 15, prvb; // number of reds used to calculate maximum points remaining on table _ prv holds previous ball potted char pact; // previous action boolean swap = true, brk = false; int point(int clr, char act){ // method receives ball colour/action _ returns points ------------------------------------------------------------------------------------------ int r=0; // reset return value for(int i = 1; i<=clr; i++){ // scan input for ball colour for(int j = 0; j<= act; j++){ // scan input for action type if(i == clr && j == act){ // when ball colour and action type match parameters/arguments from main method if(act == 'p'){ // pot! if(brk == true && pact == 'p' && (reds >=1 && (clr !=1 || prvb !=1)) || (prvb == 1 && clr == 1)){ // if brk is true and reds remaining System.out.println("While reds remain on table, you must pot a red and a colour alternately."); // error message break; } r = value[clr-1]; // return value is ball colour -1 in index if(clr == 1){ // if red ball potted, remove red from total reds *** ( POINTS REMAINING FOR ACTIVE BREAK ADDS 7)** reds--; } } else if(act == 'f'){ // foul! // if red ball fouled, ask if red has been potted and reds-- accordingly if(clr <4){ // if the value of ball fouled is less than 4 points r = 4; // minimim value for foul returned } else{ // if value of ball fouled is 4 or more r = value[clr-1]; // return ball value is ball colour -1 } } else{ // if action is not pot or foul r = 0; } } } } prvb = clr; // this ball colour is previous ball colour on next run pact = act; // this ball action is previous ball action on next run return r; } int pointsRemaining(int clr, char act){ // method to handle points remaining ---------------------------------------------------------------------------------------------- if(clr == 1 && act == 'p' || act == 'P'){ // if clr potted is red _ break is active and points for black are available return reds * 8 + 34; } else{ return reds * 8 + 27; } } } // main method ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ public class SnookerStats{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); boolean concede = false; int temp, rem, scr1, scr2; int clr; // variable to hold which coloured ball char act; // variable to hold which action // create object of class for handling scores Score obj = new Score(); // multidimensional array _ frames, balls System.out.println("Number of frames to play: "); temp = sc.nextInt(); int[][] blsprfrm = new int [temp][7]; // shot loop -------------------------------------------------------------------------------------------------------------------------------------------------------------------- while(!concede){ // if last shot was a foul _ ask fouled player if they want to put the other player back in _ if free ball occurred and player puts opponent in, minus one red // ask for concede here if points remaining are not enough --------------- // which ball colour System.out.println("Select colour:\n1 : Red\n2 : Yellow\n3 : Green\n4 : Brown\n5 : Blue\n6 : Pink\n7 : Black"); clr = sc.nextInt(); // which action System.out.println("Select from the following options:\nP : Pot\nM : Miss\nS : Safety\nF : Foul"); act = sc.next().charAt(0); act = Character.toLowerCase(act); // if shot is missed, or safety, or foul _ swap player boolean _ continue loop if(act == 'm' || act == 's' || act == 'f'){ brk = false; swap = !swap; temp = obj.point(clr, act); } // if pot or foul _ collect points to temp and give to opposite player _ if free ball, add one red if(act == 'p'){ brk = true; temp = obj.point(clr, act); System.out.println(temp); } // collect remaining points rem = obj.pointsRemaining(clr, act); System.out.println(rem + " points remaining."); } // while end // when frame is conceded _ collect statistics and print ------------------------------------ } }