EK
ekrem-bas/Tombola-Game
A classic tombola game implemented in Java using Linked Lists. Enjoy the game!
Tombola Game
Welcome to the Tombola Game, a classic bingo-style game implemented in Java! This game supports two players and allows them to compete by marking off numbers on their cards as they are randomly drawn. The game continues until one of the players achieves "Bingo" or "Tombola".
Features
- Two-player game: Each player gets a unique card.
- Random number generation: Numbers are drawn randomly, ensuring a fair game.
- Game state visualization: Players' cards are printed at each step, showing the progress.
- Bingo/Tombola detection: The game detects when a player achieves Bingo or Tombola and announces the winner.
How to Play
- Start the game:
- Run the Main class.
- Enter the names of Player 1 and Player 2 when prompted.
- Gameplay:
- Press Enter to draw the next number.
- The drawn number is announced, and each player's card is updated.
- The game continues until one player achieves Bingo or Tombola.
- End the game:
- The game will automatically announce the winner and end when a player wins.
- You can also type stop and press Enter to exit the game early.
Code Structure
- Main.java: The main class that sets up the game, handles user input, and controls the game loop.
- Cards.java: Handles the generation and display of tombola cards.
- MultiLinkedList.java: A custom linked list implementation to manage the game state.
- Node.java: Represents a node in the linked list.
Classes and Methods
Main.java
- main(String[] args): The main method that initializes the game.
- convertIntegerArraysToString(int[][] card): Converts integer arrays to string arrays for display.
- generatePermutation(int size): Generates a permutation of numbers from 1 to size.
Cards.java
- generateNumbersArray(int[][] numbers): Fills the numbers array according to tombola card rules.
- generateTombolaCard(int[][] card): Generates a tombola card with unique numbers.
- printArray(String[][] card, String name): Prints the tombola card for a player.
- checkStringArray(String[][] card, int data): Updates the card to mark the drawn number.
- checkArray(int i, int j, int[][] card): Checks if a position in the card can be filled.
- getRandomNumberForColumn(int column): Generates a random number for a given column.
MultiLinkedList.java
- add(T data): Adds a node to the list.
- addChild(T data): Adds a child node to the list.
- addGrandChild(T data): Adds a grandchild node to the list.
- checkFirstLine(T data): Checks the first line for the drawn number.
- checkSecondLine(T data): Checks the second line for the drawn number.
- checkThirdLine(T data): Checks the third line for the drawn number.
- addCardToLinkedList(MultiLinkedList player, int[][] card): Adds a card to the linked list.
- checkBingoOrTombola(String player): Checks if a player has achieved Bingo or Tombola.
- removeAndGetData(): Removes and returns the data from the head of the list.
Node.java
- Node(T data): Constructs a new node with the given data.
How to Run
- Clone the repository:
git clone https://github.com/ekrem-bas/Data-Structure-Tombola-Game-Project.git
- Navigate to the project directory:
cd Data-Structure-Tombola-Game-Project - Compile the Java files:
javac Main.java
- Run the game:
java Main
Enjoy the game and may the best player win!






