Freitag Software
The Joy of Writing Software
  • Home
    • Links
  • My Software
    • JavaScript Programs >
      • Dots
      • The Code Cracker
      • The Deserted Ship
      • Flying Text
    • Java Programs >
      • Dot Animation
      • Operation Rescue >
        • Mazes for Programmers
      • Battleship!
      • Blackjack
      • Draw Poker
      • State Pattern Demo
      • Falling Blocks
    • Android Programs >
      • The Oracle
      • RPSLS
      • Gemini Falcon: Asteroid Miner
      • Gemini Falcon: All Boxed In >
        • Gemini Falcon >
          • Privacy Policy
          • A Game Oddity
      • Ay Caramba
      • Dots vs Dots
      • Ants vs Ants
    • Twine Stories
  • Random Thoughts
  • Book Reviews
  • Teaching
    • Real-Life Stories
    • Flying Text
  • About
    • Contact

Draw Poker

Being between projects and with the holidays coming up, I didn't want to start a deep dive into any programming project so I decided to write a draw poker game since I haven't done it before. Why do a small project that students are requently assigned to do? Just to keep my programming muscles in shape. The more I code, the better I am at it (faster, more correct code). So this is a coding workout!  

I discovered some interesting programming twists when writing the code: like having to know the value of the highest card used in the hand valuation when the player and dealer have the same hand. And making Ace high had some challenges also. Good times!  

I used the following card / value mapping and initialized the deck from 0 to 51. No wild cards. 
Picture

To get the card value:  number % 13    
(% is modulus)
     Example: 48 % 13 = 9  
     which is a card with the face value of 10
and to get the suit:  number / 13
     Example: 48 / 13 = 3 which is clubs
     (0 = spades, 1=hearts, 2=diamonds, 3=clubs)




​Below are some screen shots from the game.
Download and execute the below file. 
Note: You must have Java on your computer for this to work.
 
drawpoker_ver_1_1.jar
File Size: 74 kb
File Type: jar
Download File

Picture
Picture
Picture
Picture
Powered by Create your own unique website with customizable templates.