ysamat/blackjack
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= CIS 1200 Game Project README PennKey: ysamat =:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= =================== =: Core Concepts := =================== - List the four core concepts, the features they implement, and why each feature is an appropriate use of the concept. Incorporate the feedback you got after submitting your proposal. 1. File I/O: FileIO is used to read card data from a file to initialize and manage the deck in the game. It enables dynamic loading of card information, making it easy to modify or substitute decks without changing the code. This separation ensures flexibility and integrates tightly with game logic like shuffling and dealing cards. 2. Collections: Java Collections are used to manage card data efficiently in this project. The `TreeMap` in the `Deck` class organizes cards with an integer key for predictable order, enabling easy shuffling and dealing. Additionally, `TreeMap` in the `Hand` class tracks the player's cards while simplifying score calculations and game logic. 3. JUnit Testable Component: The JUnit Testable Component is included to make sure that all classes are working as they should so that the user can have the best experience while playing the game. 4. 2D Arrays: 2D arrays in this project are used to implement the decision matrix in the GameGUI class. This matrix represents the optimal actions (hit or stand) based on the player's and dealer's scores, with rows for the player's scores and columns for the dealer's scores. By precomputing and storing these decisions, the game can quickly and efficiently determine whether the dealer should draw another card or stand during their turn. =============================== =: File Structure Screenshot := =============================== - Include a screenshot of your project's file structure. This should include all of the files in your project, and the folders they are in. You can upload this screenshot in your homework submission to gradescope, named "file_structure.png". In the screenshot, you will see the cardImages folder. This folder contains all the images to the cards used when creating the Swing Design for the game. ========================= =: Your Implementation := ========================= - Provide an overview of each of the classes in your code, and what their function is in the overall game. 1. GameGUI: This class manages the graphical user interface of the game, including player interactions like hitting, standing, and placing bets. It also controls the game logic, such as determining the winner and managing the balance and bet system. 2. Deck: Responsible for loading the deck of cards from a file, storing them in a TreeMap, and providing functionality for shuffling and accessing the cards. It ensures the deck is initialized and randomized for fair gameplay. 3. Hand: Represents a player's or dealer's hand, storing cards and calculating their total score. It also handles logic for resetting the hand and determining if the hand has gone bust. 4. RunBlackjack: Serves as the entry point to the game, initializing the GameGUI with the deck file and handling errors related to file input. It provides the main execution flow for launching the game. 5. CardScanner: A utility class that reads the deck file line-by-line and provides an iterator for processing each card. It simplifies file reading and ensures the deck is loaded correctly into the Deck class. - Were there any significant stumbling blocks while you were implementing your game (related to your design, or otherwise)? One of the stumbling blocks I hit when implementing my code was managing the switch of the value of the score of the ace card. The ace card can get complicated in blackjack, as its value depends on the total score of the hand. The main problem arised when an ace was dealt before another card. I was initially updating the total score with each card independently. Then, I realized the ace was not being properly managed, so instead of dealing with each card independently, I updated the score by recalculating it each time, changing the value of the ace if needed. - Evaluate your design. Is there a good separation of functionality? How well is private state encapsulated? What would you refactor, if given the chance? I would say there is a good separation of functionality, with classes focusing on specific tasks like GUI management, deck operations, and hand management. Encapsulation is moderately strong, as most internal states are private and accessed through methods. I still think the project could use some refactoring, such as improving CardScanner to avoid repetitive file reads and better integrating file handling within Deck. Refactoring could also focus on improving modularity in GameGUI by delegating complex decision matrix logic to a separate class or utility. ======================== =: External Resources := ======================== - Cite any external resources (images, tutorials, etc.) that you may have used while implementing your game. Link to download cards: https://code.google.com/archive/p/vector-playing-cards/downloads