Skip to content

Repository files navigation


Project Logo

BlackJack 21 Swing

An academic project developed in 2023 during the first semester of the first year for the Modelação e Programação (MOP) course at ISEL (Instituto Superior de Engenharia de Lisboa).

Explore the Documentation »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Lessons Learned
  3. Getting Started
  4. Usage
  5. Contact
  6. Acknowledgments

About The Project

vidDemoBJ21.mp4

If the embedded video above is not displaying correctly, click here to watch/download the video demo »


This repository contains **BlackJack 21 Swing**, an academic project developed in 2023 during the first semester of the first year for the *Modelação e Programação (MOP)* course at **ISEL (Instituto Superior de Engenharia de Lisboa)**. Students were given complete creative freedom to build any application within a complexity threshold required by the professor. Built entirely from scratch without starter code or base templates, the primary goal was to consolidate the Object-Oriented Programming fundamentals learned in the course by creating a desktop card game with a custom graphical interface and XML data persistence. It applies core software engineering concepts such as encapsulation, class inheritance, and user event handling in Java.

(back to top)


Built With

  • Java
  • Java Swing
  • XML DOM

(back to top)


Features & Key Highlights

  • Classic Blackjack Rules: Full implementation of standard casino rules, including automatic ace value adjustments between 1 and 11 to prevent bust hands.
  • Desktop Graphical Interface: Custom Java Swing windows featuring card graphics, interactive betting modals, and game rule overlays.
  • XML Balance Persistence: Player wallet balance is automatically loaded and saved across game sessions using XML files validated by a custom DTD schema.
  • Game History Tracking: Game outcomes and match results are logged into an XML history document that players can inspect at any time.

(back to top)


Lessons Learned

  • Object-Oriented Programming: Practiced class inheritance, encapsulation, and polymorphism when structuring game entities like players, dealers, and cards.
  • Desktop GUI Development: Learned how to design responsive Java Swing interfaces, organize layout managers, and connect interactive event listeners.
  • XML Parsing and Validation: Gained hands-on experience reading and writing structured XML files using Java DOM parsers and validating them with DTD schemas.
  • Asynchronous UI Processing: Implemented SwingWorker tasks to animate card dealing smoothly without freezing the main interface window.

(back to top)


Getting Started

Follow these instructions to set up a local copy of the project on your machine.

Prerequisites

  • Java Development Kit (JDK): JDK 8 or higher (e.g., Oracle JDK, OpenJDK, Amazon Corretto, or Eclipse Temurin)
  • IDE or Command Line: An IDE such as IntelliJ IDEA / Eclipse, or a standard command line terminal

Installation & Running Locally

  1. Clone the repository:
    git clone https://github.com/GuilhermeGraca/java-blackjack21-swing.git
  2. Navigate to the project root directory:
    cd java-blackjack21-swing
  3. Compile the Java source files:
    javac -d BlackJack21Java/out BlackJack21Java/src/tp4/*.java
  4. Run the graphical application:
    java -cp BlackJack21Java/out tp4.BlackJackGUI

Note on Card Images: Run the command from the project root directory java-blackjack21-swing so the application can automatically load the card images from the cartasPNG/ folder. If using IntelliJ IDEA, ensure your Run Configuration Working Directory is set to the project root.

(back to top)


Usage

  • Start a Match: Click the JOGAR button on the top navigation bar to open the betting window.
  • Place Your Wager: Select your bet amount to deal the initial round of cards.
  • Hit or Stand: Choose whether to draw another card from the deck or keep your current hand against the dealer.
  • Review Rules and History: Click Regras to read the game instructions or Resultados to inspect past match outcomes.

(back to top)


Contact

Guilherme Graça

(back to top)


Acknowledgments

  • ISEL — Instituto Superior de Engenharia de Lisboa: For institutional support and academic environment.
  • Modelação e Programação (MOP) Course: For the technical foundation that supported the development of this project.

(back to top)

About

A Java application that simulates a game of blackjack 21, with a java swing GUI, the results and money that the play has is stored in a XML file so that it can be used in future plays. There is also the option of playing without the GUI (just in the terminal of the editor)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages