How s31071/connectfour works
Project Overview
• The project implements a Connect Four game (4x5 variant) with a clear separation between the GUI and game logic.
• The game logic is implemented in C++ (library.cpp, ConnectFour.h) while the graphical user interface (GUI) along with user interactions are implemented in Java (ConnectFour.java).
• The project also includes unit tests (ConnectFourTest.java) to validate game conditions and board initialization.
• Communication between Java and C++ is achieved using JNI (Java Native Interface).
Identifying Main Components
• Native Game Logic (C++):
• Components: library.cpp and ConnectFour.h
• Role: Implements the core logic of the game, such as placing pieces, checking winning conditions, and game state management.
• Build System: CMakeLists.txt, which handles compiling the C++ code into a shared library for JNI.
• GUI Layer (Java):
• Components: ConnectFour.java
• Role: Handles user input (mouse drag and keyboard input), rendering of the game board, and displaying turn information.
• Unit Testing:
• Component: ConnectFourTest.java
• Role: Validates that the game logic and board configurations behave as expected.
• JNI Bridge:
• Role: Serves as the communication layer that allows the Java GUI to invoke native C++ game logic routines.
• It can be depicted as a linking/binding interface between the Java and C++ components.
Architectural Patterns and Technologies
• JNI integration: Emphasize the importance of the JNI layer as the conduit between the two languages, noting its role in translating function calls and data types.
• Testing Integration: Highlight that testing (ConnectFourTest.java) interacts with the system potentially both indirectly (via higher level GUI calls) and directly (via game logic calls), ensuring each component is verifiable independently.