posted 10 years ago
Hello there,
I’ve been working on this problem for a couple days already but I came to a point where I don’t really know what to do.
Basically I’ve got two arrays filled with int values (0, 1, and 2), which I get from Class B through their respective getMethods.
1 stands for black and 2 stands for something else.
The program counts how many times the value 1 (if chosen color is black) occurs in both arrays
and then compares the both counts. If it detects any difference the program does something else, otherwise it waits.
Here the class B.
this would be the Output:
The actual problem is that I will be getting one array at a time (meaning: the array int[] numbers from Class B updates itself and might change its values). I just declared and initialize both arrays for illustration purposes.
That would mean I need to hold the array’s values the first time I get them in a temporary variable until I get the values of the updated array. Then I could use them in the method –numberOfRelevantElements- and check if any changes have occurred.
What would be the best approach for doing this?
I though of inserting the different counts that I get into a queue and then comparing these values one after the other. But I’m not really sure if that would work.
I’d be grateful for any advice.
Thank you.