Chapter 5 Black Jack. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-2 Chapter Objectives Provide a case study example from problem statement.

Slides:



Advertisements
Similar presentations
Black Jack in Objective-C
Advertisements

500 for 2 Enjoy your favourite card game with only 2 players 500 for 2
Algebra Problems… Solutions
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 7.9Arrays of Pointers Arrays can contain pointers For.
Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view class.
© Glenn Rowe AC Lab 2 A simple card game (twenty- one)
Classes and Objects. What is Design? The parts of the software including – what information each part holds – what things each part can do – how the various.
It’s All in the Cards Adding and Subtracting Integers
Lecture 10. Simplified roulette European roulette has numbers 0,1,…36. xD0s
Dealer Comm Hand Player makes Ante bet and optional Bonus bet. Five cards are dealt to each player from the shuffler. Five cards are dealt from the shuffler.
BLACKJACK SHARKS: Aabida Mayet, Omar Bacerra, Eser Kaptan March 15, 2010.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 15 Chances, Probabilities, and Odds 15.1Random Experiments and.
12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques.
How to Play Real Estate Dough™ Negotiate Your Way to More Dough!
Computer Science 313 – Advanced Programming Topics.
Chapter 14 Ancestor Tree. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Provide a case study example from problem.
Design Example. Requirements Make a program that simulates the game of blackjack For now, we ignore money/betting…. just simulate game play But… this.
Chapter 9 Calculator. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 9-2 Chapter Objectives Provide a case study example from problem statement.
Chapter 2 Application Layer. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 2-2.
Chapter 3 Collections. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 3-2 Chapter Objectives Define the concept and terminology related.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Intro to Probability & Games
Chapter 6 Human Capital. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 6-2.
Chapter 13 Binary Search Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define a binary search tree abstract.
Chapter 16 Resources and the Environment at the Global Level.
VOCABULARY  Deck or pack  Suit  Hearts  Clubs  Diamonds  Spades  Dealer  Shuffle  Pick up  Rank  Draw  Set  Joker  Jack 
Black Jack Dr. Bernard Chen University of Central Arkansas Spring 2012.
Blackjack: Myths vs. Reality Group K Andrew KerrAndrew Phillips Sven SkoogWoj Wrona.
Refreshing Your Skills for Chapter 10.  If you flip a coin, the probability that it lands with heads up is 1/2.  If you roll a standard die, the probability.
Scavenger Hunt! 1. Pass out Scavenger Hunt worksheets 2. Break into pairs 3. Every pair should stand by a different poster (write the letter, on the poster,
Black Jack MVC By Jeremy DiPaolo. Introduction Goal: To create a Black Jack game that takes advantage of the MVC framework. Uses many of the components.
Casinos There’s a reason they are big and extravagant!
Combinations Problems Problem 1: Sometimes we can use several counting techniques in the same problem, such as combinations and the addition principle.
Learning to Play Blackjack Thomas Boyett Presentation for CAP 4630 Teacher: Dr. Eggen.
Inner and Anonymous Classes Though you are captive in the OO paradigm, you can use inner classes and anonymous classes to get around this constraint and.
Computer Science 111 Fundamentals of Programming I More Data Modeling.
EXIT NEXT Click one of the buttons below or press the enter key BACKTOPICSProbability Mayeen Uddin Khandaker Mayeen Uddin Khandaker Ph.D. Student Ph.D.
Algebra II 10.2: Use Combinations Quiz : Friday, 12/13.
1 Copyright © Cengage Learning. All rights reserved. 4 Probability.
Guide to Programming with Python
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 12.2 Theoretical Probability
Two Way Tables Venn Diagrams Probability. Learning Targets 1. I can use a Venn diagram to model a chance process involving two events. 2. I can use the.
Exceptions: Checked versus Unchecked Exceptions.
15.3 Counting Methods: Combinations ©2002 by R. Villar All Rights Reserved.
Quiz 10-1, Which of these are an example of a “descrete” set of data? 2.Make a “tree diagram” showing all the ways the letters ‘x’, ‘y’, and ‘z’
Review Homework pages Example: Counting the number of heads in 10 coin tosses. 2.2/
HAWKES LEARNING Students Count. Success Matters. Copyright © 2015 by Hawkes Learning/Quant Systems, Inc. All rights reserved. Section 2.3 Operations with.
Chapter 2 Collections. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter Objectives Define the concept and terminology related.
Objects and Classes Continued Engineering 1D04, Teaching Session 10.
MATH 110 Sec 13.1 Intro to Probability Practice Exercises We are flipping 3 coins and the outcomes are represented by a string of H’s and T’s (HTH, etc.).
Draw 3 cards without replacement from a standard 52 card deck. What is the probability that: 1.They are all red ? 2.At least one is black ? 3.They are.
Do Now. Introduction to Probability Objective: find the probability of an event Homework: Probability Worksheet.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Craps Game Application Introducing Random-Number Generation and Enum.
Week 8 : User-Defined Objects (Simple Blackjack Game)
Have you ever played a game where everyone should have an equal chance of winning, but one person seems to have all the luck? Did it make you wonder if.
The Practice of Statistics, 5th Edition Starnes, Tabor, Yates, Moore Bedford Freeman Worth Publishers CHAPTER 5 Probability: What Are the Chances? 5.2.
StructureStructure. Outline Introduction Structure Definitions Initializing Structures Accessing Members of Structures Using Structures with Functions.
The Pentium Goes to Vegas Training a Neural Network to Play BlackJack Paul Ruvolo and Christine Spritke.
Chapter 8: Arrays Gator Engineering One-dimensional array Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Move the first element to the.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Probability Rules!
Combinations 0.4. Combinations: a selection of r objects from a group on n objects where the order is not important.
Quiz: Draw the unit circle: Include: (1)All “nice” angles in degrees (2) All “nice” angles in radians (3) The (x, y) pairs for each point on the unit circle.
Discrete Optimization MA2827 Fondements de l’optimisation discrète Dynamic programming (Part 2) Material based on.
11.9: Solving Probability Problems by Using Combinations
Lecture 11.
The Addition Rule.
Chapter 5 Black Jack.
Lecture 10.
Fundamentals of Programming I More Data Modeling
Task 2 Implementation help
Presentation transcript:

Chapter 5 Black Jack

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-2 Chapter Objectives Provide a case study example from problem statement through implementation Demonstrate how a set can be used to solve a problem

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-3 Black Jack Black Jack is a card game typically involving multiple players and a dealer Each card in a hand is awarded points based upon its face value Face cards are worth 10 points each Numeric cards are worth their face value Aces are worth either 1 or 11 points

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-4 Black Jack The goal of the game is to be closer to 21 than the dealer without going over 21 Black Jack is usually played with a shoe of cards (a collection of seven decks)

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-5 Black Jack For this case study, we define black jack as a one-player v.s. the dealer interactive card game We will also limit the game to a single deck of cards rather than a shoe The player begins the game by clicking a Deal button

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-6 Black Jack The player and the dealer are then dealt two cards The player can see their own cards and one card of the dealer The player then has the choice to hit (take another card) or stay (accept this hand as final for this game) If the player busts (goes over 21) then the game is over

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-7 Black Jack Once the player elects to stay, the dealer then chooses to hit or stay The dealer must hit on 16 or less and must stay otherwise An Ace is considered to be 1 point rather than 11 points if otherwise it would cause the player or dealer to bust

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-8 Black Jack - Initial Design Our black jack game is made up of the components of the game, the function of the game, and the user interface The components include cards, deck, and players hands The function includes controlling the order of play, whether a player hits or stays, and the value of a players hand

Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-9 Black Jack - Initial Design In this case study, there is a clear distinction between the low-level components of the game and the game itself These low-level components (card, deck, hand) are also very well defined in terms of state and behavior Thus a bottom-up approach to this design problem makes sense

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - Initial Design Bottom-up simply means that we will design the low-level components first and then work our way up to the driver Other approaches include top-down and re- use based design Keep in mind, these are simply frameworks not rigid models Thus we will often find ourselves mixing these approaches even on the same system

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the Card Class A Card object must represent: – the suit of the card (heart, diamond, club, or spade), – the value of the card (1 to 11), – the face of the card (ace, king, queen, six, two, etc.), – the image of the card A Card object must also provide a constructor, operations to: – retrieve the suit, value, face, or image of the card, – an operation to change the value of an ace from 11 to 1

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the Deck Class A deck is an unordered collection of unique cards Thus a set is a perfect collection to represent a deck The Deck class must include – the collection of Cards, – a method to retrieve a random card from the deck

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the Deck Class We will also choose to instantiate a new deck at the beginning of each new game This eliminates the possibility of ever having an “empty” deck during a game

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the Hand Class A hand is a collection of unique cards that have been dealt to a player A Hand object must keep track of: – the cards in the hand, – the count of the cards in the hand, – the value of the hand A Hand object must also provide methods to: – add a card to the hand, – remove a card from the hand, – return the value of the hand, – provide a string representation of the hand

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the Hand Class A Hand object must also provide a method to determine if an ace is in the hand and needs to be reduced in value from 11 to 1 As with a Deck, a set seems a reasonable collection to represent a Hand since each of the cards in the Hand are unique and order does not matter

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the BlackJack Class Separating the function of the game from the user interface, we will have a BlackJack class to control the game and a BlackJackGUI class to provide the interface The BlackJack class must represent – the hands of both players – the deck

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the BlackJack Class This class must provide methods to: deal the initial cards, hit a particular player, return the value of a player’s hand, determine is a player has busted, determine the winner of the game The BlackJack class will use the Deck class to store the deck and the Hand class to represent each player

Copyright © 2005 Pearson Addison-Wesley. All rights reserved Black Jack - the BlackJackGUI Class The BlackJackGUI class will provide the user interface for our game This class will provide: a deal button, buttons for the player to hit or stay, a display of each player’s hand a display of the winner of the game

Copyright © 2005 Pearson Addison-Wesley. All rights reserved FIGURE 5.2 User interface design for BlackJack

Copyright © 2005 Pearson Addison-Wesley. All rights reserved BlackJack - the BlackJackDemo Class The BlackJackDemo class will serve as the driver for our system This class simply creates an instance of BlackJackGUI and calls its display method

Copyright © 2005 Pearson Addison-Wesley. All rights reserved FIGURE 5.1 Blackjack class diagram