Landing : Athabascau University

Section 5.4 - Programming Example - Card - Hand - Deck: Revision

An overview of the Blackjack Card Game: Java & Object-Oriented Programming. Chapter 5. 

While reading through chapter 5 of text, I reviewed the algorithm for the Blackjack game provided in text and attempted to not only compile and to make it run. I also reviewed another blackjack game online, went through code line by line and although I am still having some challenges getting these two card games to compile without errors, here are a few of the important points that I picked up from these games.

  • Both games are different in terms of their implementation and gameplay.

Key differences:

Card Game 1: Source: hundredvisionsguy: Create a Java Card Game Project using OOP: https://www.youtube.com/watch?v=5FxWZOV3f9A&list=PLlmV8hCw8wblhfOeesNFABDq4gQHc2CL_ :Accessed 20th December 2023

Components:

  1. Game Class: Main class for running the game. It creates a deck, deals cards to players, and shows hands.
  2. Card Class: Represents a playing card with a rank, suit, and whether it's face up or down.
  3. Rank Enum: Defines the ranks of cards (e.g., Ace, King, etc.).
  4. Suit Enum: Defines the suits of cards (e.g., Hearts, Spades, etc.).
  5. Hand Class: Represents a player's hand, with methods for adding, clearing, flipping cards, and calculating total points.

Gameplay:

  • Players are dealt hands from a shuffled deck.
  • Players can flip their cards.
  • The dealer's first card is flipped.
  • The total points for each player's hand are shown if all cards are face up.

Card Game 2: Source: Eck, D. J. (2019, July). Introduction to Programming Using Java (Version 8.1). Accessed 15th December 2023

Components:

  1. HighLow Class: Main class for playing the HighLow card game. Manages game flow, scoring, and user interactions.
  2. Deck Class: Represents a deck of playing cards with methods for shuffling, dealing, and checking the number of cards left.
  3. Card Class: Represents a playing card with a suit and value.
  4. Rank Enum: Constants for the card ranks (Ace, Jack, Queen, King).
  5. Suit Enum: Constants for the card suits (Spades, Hearts, Diamonds, Clubs, Joker).

Gameplay:

  • Users play a simple card game (HighLow) where they predict if the next card will be higher or lower.
  • The deck can include Jokers.
  • Users play multiple games, and the average score is calculated and displayed.

Key Differences:

  1. Game Type:
  • Card Game 1: Traditional card game with hands and a dealer.
  • Card Game 2: HighLow card game where users predict the next card.

    2. Components:

  • Card Game 1 has separate classes for Card, Rank, Suit, Hand, and Game.
  • Card Game 2 has classes for HighLow, Deck, Card, Rank, and Suit.

    3.     Game Flow:

  • Card Game 1 deals hands to players, flips cards, and shows totals.
  • Card Game 2 involves predicting if the next card is higher or lower.

     4.     Enums:

  • Card Game 1 uses Rank and Suit enums for card properties.
  • Card Game 2 uses Rank and Suit enums along with additional constants.

5.     Deck Handling:

  • Card Game 1 does not explicitly show deck handling.
  • Card Game 2 includes a Deck class with methods for shuffling and dealing.

6.     User Interaction:

  • Card Game 1 doesn't involve direct user input.
  • Card Game 2 requires user input for predicting the next card.
  • Overall, these are two distinct card games with different rules and implementations. Card Game 1 is more traditional, while Card Game 2 is a simplified HighLow game.