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
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.
- 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.
- 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.
Follow these instructions to set up a local copy of the project on your machine.
- 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
- Clone the repository:
git clone https://github.com/GuilhermeGraca/java-blackjack21-swing.git
- Navigate to the project root directory:
cd java-blackjack21-swing - Compile the Java source files:
javac -d BlackJack21Java/out BlackJack21Java/src/tp4/*.java - Run the graphical application:
java -cp BlackJack21Java/out tp4.BlackJackGUI
Note on Card Images: Run the command from the project root directory
java-blackjack21-swingso the application can automatically load the card images from thecartasPNG/folder. If using IntelliJ IDEA, ensure your Run Configuration Working Directory is set to the project root.
- 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.
Guilherme Graça
- LinkedIn: guilherme-graça
- GitHub: @GuilhermeGraca
- Project Link: https://github.com/GuilhermeGraca/java-blackjack21-swing
- 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.