Proof of Completion and Running on Open Coding Society Code Runner Part A

Proof of Completion and Running on Open Coding Society Code Runner Part B

Area of Stuggle
An area of struggle for me is using the correct syntax. I will have the correct idea on how to write the correct code, by planning out a pysudocode verison in my head and then thinking about how that would be written in Java. I understand how to write the code but, sometimes I make mistakes with my syntax which happened many times for example forgetting semicolon, incorrect bracket, didn’t indent correctly. These errors caused the code runner to have an error and it allowed me to debug. This is something i should work on fixing and improving, so I get better with avoiding syntax errors on AP Exam.
Key Takeaways
-
Boundary Checking is Essential: When accessing array elements like
blackSquares[r-1][c], always check if you’re at an edge first (r == 0 or c == 0) to avoid ArrayIndexOutOfBoundsException. -
Break Down Complex Boolean Logic: Instead of writing one long compound boolean expression, use multiple if statements to make the logic clearer and easier to debug.
-
Use Helper Methods: The
toBeLabeledmethod is reused in the constructor, showing how breaking code into smaller methods makes the overall solution cleaner. -
Track State with Counters: Using a counter variable like
labelNumthat only increments under certain conditions is a common pattern for numbering or labeling elements. -
2D Array Traversal: Nested for loops with row and column indices are the standard way to process 2D arrays, accessing dimensions with
.lengthand[0].length.