You are going to create a simple card game of 21. In this game, the .docx - You are going to create a simple card game of 21 In this game the single

You are going to create a simple card game of 21. In this game, the .docx

This preview shows page 1 - 4 out of 11 pages.

Image of page 1
You are going to create a simple card game of 21. In this game, the single player has to try to come as close to a score of 21 without going over and beat the computer\'s score.1. Set up a class called PlayingCard. Add a method that returns a string representing its rank and suit. For example, the card with rank 1 and suit \'S\' is \"Ace of Spades\".2. Set up a class called DeckOfPlayingCards which contains the following information:INSTANCE VARIABLESan array of 52 PlayingCard objectsindex of the \"top\" card in the deckMETHODSconstructor - initializes each PlayingCard object to a unique card in a standard deckshuffle - randomly permute the order of the cards in the array (see below for a hint) and sets the top card to the first card in the arraydeal - returns the top card in the deck and sets the top card index to the next card3. Set up a class TwentyOne with a main method that creates the deck of cards and then allows the user to play the game of21.SHUFFLINGIn order to shuffle the cards, use similar to the following algorithm:for i = 0 to 50pick a random integer j between i and 51
Image of page 2
swap card i with card j end for GENERAL GAME RULES Each card has a point value based on its rank (the suit is ignored in this game). The cards with ranks 2 through 10 have point values of 2 through 10 respectively. The \"face\" cards (Jack, Queen, King) have a point value of 10 each. The Ace is considered as 11 points, unless that puts the player over a total of 21 points, in which case it reverts to 1 point instead. For example, the
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 11 pages?

  • Fall '19
  • Playing card, simple card game

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture