Blackjack_Game - johnelwart/Projects GitHub Wiki

Home

Problem Statement

This goal of this project is to create a blackjack game that uses networking to deal cards to each player and then deal additional cards to each player upon request.

Developer Documentation

The card class contains all the values of each card instance including suit, rank, and value. It also has a toString method that prints out the card selected in the format of a string. The deck class contains a method called createDeck that creates all the cards in a standard playing card deck and adds them to an arrayList that represents the deck. It also has a method that randomly draws a card from the deck using a random number and removes it. BlackjackServerTest and BlackjackClientTest create a new server and client respectively when run. The majority of the game code that determines who should be playing at a certain time and what the state of the game is is located in the BlackjackServer class. The bulk of this class is the run method that contains a while loop to keep the game going until all 3 players have gone or one of the players gets a 21. While its a players turn, the loop is looking for new inputs to the stream from the client to process. When one shows up the server decides if the command is valid and handles the output based of the conditions it meets. After each of the clients have played, the server deals cards to itself until it has a higher score than both of the players or if it goes over 21. Once the dealer plays, the game is over and the results are printed to the screen. The BlackjackClient class contains code that processes each of the outputs sent by the server to display messages in the output area of the GUI. Those messages can include the current state of the game, Who won when the game ends, or what card was drawn when the player requests one.

User Documentation

The client application has a GUI that contains two buttons to either draw a card or stand and end their turn. Until the player selects stand or they go over 21 it remains their turn. Once when of those conditions are met, it becomes the next players turn. When it is another players turn, the buttons will not do anything when clicked. The server GUI does not have buttons to draw or stand but does all of the drawing automatically and then decides when to end their turn based of conditional statements.

Source code

Source Code