Create a class deck that represents a deck of cards

Assignment Help Basic Computer Science
Reference no: EM131302277

Create a class Deck that represents a deck of cards. Your class should have the following methods:
constructor Creates a new deck of 52 cards in a standard order.
shuffle Randomizes the order of the cards.

dealCard Returns a single card from the top of the deck and removes the card from the deck.
cardsLeft Returns the number of cards remaining in the deck.

Test your program by having it deal out a sequence of n cards from a shuffled deck where n is a user input. You could also use your deck object to implement a Blackjack simulation where the pool of cards is finite. See Programming Exercises 8 and 9 in Chapter 9.

Exercises 8:

Blackjack (twenty-one) is a casino game played with cards. The goal of the game is to draw cards that total as close to 21 points as possible without going over. All face cards count as 10 points, aces count as 1 or 11, and all other cards count their numeric value.

The game is played against a dealer. The player tries to get closer to 21 (without going over) than the dealer. If the dealer busts (goes over 21), the player automatically wins (provided the player had not already busted). The dealer must always take cards according to a fixed set of rules. The dealer takes cards until he or she achieves a total of at least 17. If the dealer's hand contains an ace, it will be counted as 11 when that results in a total between 17 and 21 inclusive; otherwise, the ace is counted as 1.

Write a program that simulates multiple games of blackjack and estimates the probability that the dealer will bust. Hints: treat the deck of cards as infinite (casinos use a "shoe" containing many decks). You do not need to keep track of the cards in the hand, just the total so far (treating an ace as 1) and a bool variable hasAce that tells whether or not the hand contains an ace. A hand containing an ace should have 10 points added to the total exactly when doing so would produce a stopping total (something between 17 and 21 inclusive).

Exercises 9:

A blackjack dealer always starts with one card showing. It would be useful for a player to know the dealer's bust probability (see previous problem) for each possible starting value. Write a simulation program that runs multiple hands of blackjack for each possible starting value (ace-10) and estimates the probability that the dealer busts for each starting value.

Reference no: EM131302277

Questions Cloud

What is the projects year zero net cash flow : Down Under Boomerang, Inc., is considering a new three-year expansion project that requires an initial fixed asset investment of $2.73 million. The fixed asset will be depreciated straight-line to zero over its three-year tax life, after which time i..
How does organizational culture impact the change process : Consider what you watched in the videos as well as what you have learned in the course up to this point.How does organizational culture impact the change process?Reflect on your experience dealing with change. Explain whether you are naturally open t..
Calculate the approximate bit rate and signal level : The address depletion of IPv4 and other shortcomings of this protocol prompted a new version of IP known as IPv6. Explain the advantages of this new IPv6 when compared to IPv4?
Did the author follow anthropological theory and methods : Did the author follow anthropological theory and methods in his/her article? What did you agree with in this article. What did you not agree with this article? Would you recommend this book to others? Why or why not?
Create a class deck that represents a deck of cards : Blackjack (twenty-one) is a casino game played with cards. The goal of the game is to draw cards that total as close to 21 points as possible without going over. All face cards count as 10 points, aces count as 1 or 11, and all other cards count t..
What was the capital gain of the tips in dollars : TIPS Capital Return Consider a 4.50% TIPS with an issue CPI reference of 188.50. At the beginning of this year, the CPI was 199.30 and was at 206.00 at the end of the year. What was the capital gain of the TIPS in dollars?
Examples for the three basic approaches : Discuss, explain in detail and provide examples for the three basic approaches to coping with the other party that offers an uncompromising position.
What is the cost of preferred stock : Holdup Bank has an issue of preferred stock with a $4.45 stated dividend that just sold for $81 per share. What is the bank's cost of preferred stock?
Find volume enclosed by surface using monte carlo simulation : A three-dimensional surface is defined.- How many points did you need to generate before you became 90% confident that your error was less than 1%?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Centralized or decentralized account

Is an account created in Window 7 VM a centralized or decentralized account. If you wanted to log onto a second computer using the same username and password, what would you need to do first?

  What communication is appropriate for each party

After reading the following scenario, determine how to communicate its negative information appropriately to your supervisor or manager, to the members of your project team, and to your travel agent in the scenario.

  What is the swap space amount for the bash command

If using a long listing and no process modifiers, what is the swap space amount for the bash command?

  What are the binary values in the nine inputs of the circuit

What are the binary values of the five outputs of the circuit? Explain how the output is related to the operation of 6 - 9.

  Have methods to clear the machine state

Implement a VotingMachine class that can be used for a simple election. Have methods to clear the machine state, to vote for a Democrat, to vote for a Republican, and to get the tallies for both parties.

  What design patterns are offered and how are they used

Research a GUI development environment and show how the user interaction component is implemented in the real world. What design patterns are offered and how are they used?

  How big would a transistor be on next year''s model

how big would a transistor be on next year's model

  Create a list containing the union of the elements

Create a list containing the union of the elements of the two lists? Insert an element after the nth element of the list.?

  Security policy framework

You will create an organizational security plan policy using your assigned readings (pay close attention to Chapter 3 in the Building an Effective Information Security Policy) as well as the Cybersecurity Framework  as a resource, creating a two ..

  Router cidr entries for ip addresses

A router has the following (CIDR) entries in its routing table:

  Should is blank be public protected or private explain

What small change(s) would you make to the classes to ensure that the correct version of isExpression is called?

  What other motivations may prompt such alliances

Discuss the reasons that companies embark on cross-border strate- gic alliances. What other motivations may prompt such alliances?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd