So in my class we are working a simple Tetris like applet in Java. Blocks fall from the top of the screen into 6 different columns and each different column is a stack. In order to score points you must match 3 or more blocks of the same color directly next to each other horizontally on the very top of the stacks. So only the top of the stacks can match. If you match 3 or more blocks, they must be removed (aka pop()'d off). You are allowed to switch blocks with the adjacent blocks to either the right or left (thus generating larger combos). However that is my issue. My issue involves checking whether or not 3 or more blocks (that are adjacent to each other) are matching in color. What I have to keep in mind is the possibility that the number of columns may increase. I am not saying it will increase when the program runs, it's just I have to practice proper technique and make sure I am approaching this issue with that as a possibility. With that said there is a member variable that represents the number of columns, aptly named numCols.
So if anyone could give me a push in the right direction to solving this problem please. Again, the problem: being able to write a method removeCombos() that checks for 3 or more blocks of the same color in a row horizontally (across the top of the stacks) and remove them. I want to write the code myself that's why I have not provided any code here. Unless there is something you need to see then I could provide some, but it's working with basic stack class and its generic methods, pop(), peek(), contains(), isEmpty(), as well as an iterator class within the stack class.
If I have been unclear in any way I apologize in advance and please ask me to clarify where needed. Thank you very much.