Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Object From ArrayList

$
0
0
Hello all,

ok, Im sure this is something simple but I just cannot seem to figure it out.

I am buiulding an object of a bingo pattern, In it holds the key to a correct bingo, the name of the bingo and the image name of the bingo pattern.
import java.util.ArrayList;


public class BingoPattern {
    
    //hold correct slots for winning bingo's
    public ArrayList <Integer> keyList = new ArrayList<>();
    //Pattern name for show
    String patternName;
    //Pattern Image Name for images
    String imageName;
    
    BingoPattern(String keys, String name, String in) {
        
        patternName = name;
        imageName = in;
        
        String T1[] = keys.split(":");
        
        for(int i=0;i<T1.length;i++) {
        
                keyList.add(Integer.parseInt(T1[i]));
            
        }
        
    }
    
    public String getPatternName() {
        return patternName;
    }
    
}


now the problem is that I am trying to access it from within my "GameFlow" class but I cannot seem to figure out how to do so?

First off I am building an Object arraylist in Server class above the constructor

        //objects for game patterns
        ArrayList <Object>GamePattern = new ArrayList<>();


then in the constructor I am building the objects and adding them to the arraylist:
                GamePattern.add(new BingoPattern("0,4,6,8,16,18,20,24","The Letter X","X"));
                GamePattern.add(new BingoPattern("0,1,2,3,4,9,14,19,24","The Letter L","L"));
                GamePattern.add(new BingoPattern("0,6,18,24","Regular Bingo","R"));


then in Gameflow I am trying to call to the object to get the name as so:
                int HGameSet = sv.selectPattern();
                String HGameName = sv.GamePattern.get(HGameSet).getPatternName();

please note that sv is the object that i built in GameFlow to communicate between gameflow and Server and the selectPattern() method just returns a random number between the amount of objects in GamePattern arraylist

But I am getting this error:

Cannot find symbol
symbol Method: getPatternName()
location class.java.lang.object


Thank you for any help

I can post more code if needed but that is all the code that has anything to do with the issue and I didnt want to weight down the question with a bunch of unneeded code.

Bob

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>