Blackjack Programming Assignment

Purpose

The purpose of this assignment is to design and implement aJava program that simulates a solitaire version ofBlackJack.

Question: Python Problem In This Assignment, We'll Be Developing A Simplified Version Of Blackjack, But It Will Be More Complex Than The One For Assignment 4. Please Read Following Descriptions Carefully. At The Start Of A New Hand, The Player Will Be Dealt Two Cards. The Player Will Then Choose, With A Goal Of Obtaining A Set Of Cards That Sum As Close To 21. In this program, you will use four classes to write a (very simplied) Black- jack game. Blackjack is a popular card game. The game is played between two players as follows. Each player takes three cards from the deck.

Partners

You may (and are encouraged to) work with at most one other partner on this assignment. You and your partner must be in the same lab section. If you workwith a partner, submit one solution with both of your names on it.

Assignment

Create a BlueJ project named Program3 and placethe following files in it:

Your task is to modify the CardDeck and Card classessuch that a solitaire version of BlackJack (described below)can be simulated. The BlackJack class should be leftalone and not modified.

BlackJack Solitaire Background

Before the simulation is begun, the user will be askedto supply a lower bound between 1 and 21. Call thisvalue lowerBound.

Each time a game is simulated, the following stepsshould occur:

  1. Shuffle a regular, 52 card deck of cards.
  2. Deal the cards one at a time. If the total value of the cards dealt is ever greater than or equal to lowerBound and less than or equal to 21, the game is won. If the total value of the cards dealt ever exceeds 21, the game is lost.

In BlackJack, the value of a card is as follows:

  • A two is worth 2 points.
  • A three is worth 3 points.
  • A four is worth 4 points.
  • A five is worth 5 points.
  • A six is worth 6 points.
  • A seven is worth 7 points.
  • An eight is worth 8 points.
  • A nine is worth 9 points.
  • A ten is worth 10 points.
  • A jack is worth 10 points.
  • A queen is worth 10 points.
  • A king is worth 10 points.
  • The first ace in the hand is worth 11 points, unless this ever makes the total value of the hand exceed 21 points. In this case, the first ace should be reevaluated to be worth 1 point. All subsequent aces are worth 1 point.

Getting Started

The three files that you are given will compile and run. Make surethat you understand them well before beginning. Notice that theCardDeck class contains the following methods that currentlydo nothing:

  • initializeSimulation - the method should initialize appropriate instance variables before the BlackJack simulation begins.
  • simulateBlackJack - the method should simulate one game of BlackJack solitaire and record whether the game was won or lost.
  • getWins - the method should return the total number of times that BlackJack solitaire was won.
  • getLosses - the method should return the total number of times that BlackJack solitaire was lost.

Grading (50 points possible)

Blackjack Programming Assignment Examples

  • 5 points - the simulation works correctly for the range [1, 21].
  • 5 points - the simulation works correctly for the range [11, 21].
  • 5 points - the simulation works correctly for the range [17, 21].
  • 5 points - the simulation works correctly for the range [18, 21].
  • 5 points - the simulation works correctly for the range [19, 21].
  • 5 points - the simulation works correctly for the range [20, 21].
  • 5 points - the simulation works correctly for the range [21, 21].
  • 5 points - CardDeck.java and Card.java contain appropriate comments, javadoc and otherwise.
  • 5 points - the code that performs the simulation is reasonably efficient.
  • 5 points - the code in CardDeck.java and Card.java is understandable and well written.

Submission

E-mail the CardDeck.java and Card.javafiles as an attachment to your lab TA nolater than the start of your lab on Tuesday, October 28th.Late submissions receive no credit, but partial credit canbe earned by making an ontime submission.The subject of the e-mail should be CS 160, Program 3,your name, your partner's name.

The Python Programming class that I taught in the spring 2009 semester studiedhow to program graphical user interfaces. The final project of the class wasto design an object oriented black jack card game with a graphical userinterface. Described on the following pages is my implementation.

This class was taught as a lower level CMST elective. Thus it was anintroductory programming class. The text book that we used was: PythonProgramming: An Introduction To Computer Science, by John Zelle. This bookuses graphics programming as a means to introduce object oriented programming.Thus, the book provides an object oriented module called graphics, whichhas facilities for displaying basic graphics primitives such as circles,squares, lines and also has a method to catch mouse click events returning thex,y coordinates of where the mouse was clicked. Based on this module, abasic button class is developed. This graphics module is an objectoriented wrapper around Python’s standard tkinter module. Thegraphics module is in one sense an improvement on tkinter becauseit is object oriented, but much of the functionality of tkinter isremoved, including the main loop that generates function backs based on event,such as mouse clicks and keyboard data entry. Thus, the first order ofbusiness to seriously use this module was to write a class to provide eventdriven method call backs. I wrote this class and used it to teach the basicconcepts of asynchronous event driven programming. The journey from having avery basics graphics module to having an event driven programming framework toa final working black jack game was excellent from a teaching perspective.From talking to the students, I’m quite certain that a number of studentsadvanced tremendously as programmers from this assignment. However, from justa pure programming perspective, the graphics framework that we used was fairlypoor. Starting with a mature graphics framework, such as wxPython, as I did with the Multi-party Chat Client and Server and Graphical Weather Forecast Viewerapplications is a much preferred way to write a graphical application.However, my prime objective here was not to write a black jack application, butto teach object oriented programming, and that most certainly was accomplished.

Blackjack Programming Assignment Example

Blackjack

Blackjack Programming Assignment Questions

Contents: