This Java project is an implementation of the popular Payday board game. The game follows the Model-View-Controller (MVC) design pattern, dividing the codebase into three main packages: Model, View, and Controller.
The Model package encompasses eight sub-packages:
-
Cards: Defines abstract classes for different types of cards, including deal and message cards.
-
Deck: Implements the two decks from which players draw cards (deal and message decks).
-
Tile: Defines an abstract class for various game tiles, such as buyer, casino, deal, and more.
-
Board: Represents the game board as an array of tiles.
-
Player: Contains variables describing player-specific data, such as balance, loan amount, score, and player cards.
-
Pawn: Implements the pawns used by each player.
-
Dice: Represents the dice used in the game.
-
Jackpot: Handles the game's jackpot functionality.
Below we can observe a UML diagram of the whole model package
The Controller package is responsible for facilitating communication between the Model and View components. It defines methods for initializing, controlling, and updating the game. Key methods include those for setting up decks, tiles, listeners for UI elements, determining game completion, finding the winner, and managing player actions during the game.
The View package divides into three classes, each representing a portion of the graphical user interface (GUI):
-
BoardPanel: Extends JLayeredPane and creates the panel for displaying the game board and jackpot. It takes a Model instance as an argument and provides an
update()
method to refresh UI elements based on the game state. -
InfoBoxPanel: Extends JTextArea and creates a panel for informing players of the game's status and required actions. It offers methods for updating player-specific information and messages.
-
PlayerBoxPanel: Extends JPanel and displays individual player information, including balance, loans, bills, and buttons for player actions. It takes a Player instance as an argument and provides an
update()
method to keep player data up to date. -
View: Utilizes the above classes to construct the game's graphical user interface. It defines a JFrame as the main frame and offers methods for updating the UI components, such as players' information and game messages.
We also can picture how the View package is implemented in the following diagram.
The Model component consists of various sub-packages, each responsible for different aspects of the game's logic, such as cards, tiles, players, and the game board. These packages contain classes and methods that collectively define the game's rules and state.
The Controller component acts as an intermediary between the Model and View components. It defines methods for initializing the game, managing player actions, and handling game progression. The Controller makes decisions based on user input and updates the Model and View accordingly.
The View component comprises three main classes, each responsible for rendering specific elements of the GUI. The View class orchestrates these components to create the complete game interface, ensuring that player information, the game board, and messages are displayed correctly.
A complete UML diagram of the whole project, highlights the MVC design pattern that was used, as the controller acts as a mediator between the Model and the View, whilst the latter do not have any immediate communication.
This Java implementation of the Payday board game adheres to the MVC design pattern, offering a structured and efficient way to model, control, and visualize the game. The separation of concerns in the Model, Controller, and View packages ensures a clear and maintainable codebase, making it easier to extend and enhance the game in the future.
For detailed information on how to run the game and its rules, refer to the project's PDF report.
This project is licensed under the MIT License.