I am processing lines of txt file which contains 4 boolean characteristics. I want to pass a boolean[] into a method with a reference to which line it came from (which line is defined by another variable on the line which is incremental, just not necessarily ordered).
Is there a way to create an array, of some sort, with a reference to the line variable and then the 4 booleans from that line?
If not directly, I can use 0 and 1 to represent false and true respectively eg. array[i][0] = 0; and then transfer this into a boolean in the receiving method:
boolean charone = (array[i][0] == 1) ? true : false;
Edit: The characteristics represent whether a coordinate on the line is at a maximum of the symbol described by the whole txt file.
Pattern patternx = Pattern.compile("(?<=(<))((-)*?(\\d+))(?=(,))");
Pattern patterny = Pattern.compile("(?<=(,))((-)*?(\\d+))(?=(>))");
for(String pin : pins){
boolean sidemax = false;
boolean sidemin = false;
boolean top = false;
boolean bottom = false;
int i = Integer.parseInt(pin.split(" ")[1]);
Matcher matcherx = patternx.matcher(pin);
Matcher matchery = patterny.matcher(pin);
while (matcherx.find()){
String numb = matcherx.group(0);
int x = Integer.parseInt(numb);
if (x >= maxx) {
sidemax = true;
}
if (x <= minx){
sidemin = true;
}
}
while (matchery.find()){
String numb = matchery.group(0);
int y = Integer.parseInt(numb);
if (y >= maxy) {
top = true;
}
if (y <= miny) {
bottom = true;
}
}
Is there a way to carry through sidemax, sidemin, top, and bottom into another method by adding them directly to an array of every line passed in, such that the array would be 2D with the top layer being a reference and the bottom layer being 4 booleans?
Java is an Object Oriented Language. Create classes to represent your data:
When reading the file, create instances of the above
Lineclass, and pass these instances to the methods who need the 4 boolean values and the number of the line where they come from.