Blackjack Application and Applet
Click here to play Blackjack!
This project was created as a final project for the Honors Freshman Seminar; a class created by the College of Computer and Information science at Northeastern University, and taught by Prof. Richard Rasala. The purpose of this project was to generate a project that would demonstrate two points. The first being that one can learn to program simply by analyzing other code, understanding what it does, and adapting it to your needs. The second purpose is to demonstrate the ease of GUI building when utilizing the Java Power Tools (JPT). For more information on JPT, click here.
You can download (and in Safari, Mozilla, of Firefox, view) the files below by clicking on their names. To run these files on your own computer, you need to first retrieve the jpt.jar file from the JPT site. Second, you should download the BlackJack.zip file, which contains all of the .java and image files needed for both the application and applet.
Code Common to the Application and Applet
BlackJack.java
The class that initializes the game, controls basic game actions, and constructs the GUI.
Card.java
The class that contains the object constructor for the card.
Person.java
The class extended by the Player and Dealer classes, it contains the function that calculates the total, as well as the function that places card images into the GUI.
Player.java
The class that controls all aspects of the Player's hand and extends the Person class. Contains the construct to make a player.
Dealer.java
The class that controls all aspects of the Dealer's hand and extends the Person class. Contains the construct to make a dealer. Also contains the dealer's AI.
ImageTile.java
Creates tiles for the GUI from images.
ProbStatTools.java
The class that contains mathematical functions, which, in this case, are used to shuffle the deck.
This is the .txt file which contains the import order for the images.
Card Images
Code Specific to the Application
Deck.java
This class contains the contructor for a deck, calls the ImageTools class to import the images, and contains the shuffle method.
FileNameTools.java
This class handles reading image file names from a .txt file in the image directory.
ImageTools.java
This class imports image files from an image directory. It will import in the order obtained from a .txt file, or, by default, in alphabetical order.
Code Specific to the Applet
BlackJackApplet.java
This class constructs the Java applet.
Deck.java
This class contains the contructor for a deck, calls the images class to import the images, and contains the shuffle method.
images.java
This class calls the WebTools class to get the file names, then uses these names to get the image files.
WebTools.java
This class reads the .txt file containing the names of all the images, and prepares an array of strings used to import the images
The HTML That Activates the Applet
<applet
code="BlackJackApplet.class"
archive="http://www.ccs.neu.edu/jpt/jpt_2_3/lib/jpt.jar"
width="200"
height="50"
>
<PARAM
NAME="imagesURL"
VALUE="./applet/images/"
>
</applet>