Create a class deck that represents a deck of cards

Assignment Help Basic Computer Science
Reference no: EM131305053

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: EM131305053

Questions Cloud

How can you dictate your future : How can you best manage whenever you do not have the means to dictate your future?
Write a program that creates a list of card objects : Your program should read the list of cards from a file, where each line in the file represents a single card with the rank and suit separated by a space. Hint: first sort by rank and then by suit.
How do banks manage liquidity risk : What is liquidity risk? How do banks manage liquidity risk?- What is credit risk? How do banks manage credit risk?
Was the liquidity risk faced by banks : Before 1933, there was no federal deposit insurance. Was the liquidity risk faced by banks during those years likely to have been larger or smaller than it is today? Briefly explain.
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..
Whether you agree with the given statements : Explain whether you agree with the given statements:- "A bank that expects interest rates to increase in the future will want to hold more rate-sensitive assets and fewer rate-sensitive liabilities."
What is your estimate of the current share value : You expect firm XYZ to pay a dividend next year of $0.50, in year 2 of $0.60, and in year 3 of $0.75. If you expect the stock to sell for $35 in three years and the required rate is 10%, what is your estimate of the current share value (price per sha..
Consider the two mutually exclusive projects : Consider the following two mutually exclusive projects: Cash Flows ($) Calculate the NPV of each project for a discount rate of 14%. What is approximately the IRR for each project individually?
Determine the use of the forecast : Discuss about the Operations Management Forecasting for Retail and Real Estate Industries.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What are the contextual and behavioral attributes

How is the relationship among objects modeled in collective outlier detection?

  Value of the common stock

Header Motor inc paid a 3.45 dividend last year. At a constant growth rate of 4 percent what is the value of the common stock if the investors require a 10 percent rate of return?

  Manufacturer of fine cosmetic soap products

Handcrafted Soap is a manufacturer of fine cosmetic soap products. Sweet Treats' two main products are soap and cleanser. Each batch of soap consumes 50 pounds of glycerin and 30 pounds of oil. Each batch of cleanse consumes 20 pounds of glycerin and..

  Performance and reliability of a network

How could this group's work help a network designer characterize an existing network?

  Produce a distributed database design for this system

Using the ER diagram from the previous question, produce a distributed database design for this system

  What is the meaning of collocated control

For a structural process to be controlled, such as a robot arm, what is the meaning of "collocated control"? "Noncollocated control"?

  What are the different types of qa activities

What are the different types of QA activities? Do you know any classification other than the one described in this chapter based on how they deal with defects?

  System administrator at sls happened to read the details

Suppose a system administrator at SLS happened to read the details of this case. What steps should he or she take to improve the company's information security program?

  This assignment involves relating ethical behaviors

This assignment involves relating ethical behaviors in high-profile events, as well as examining regulatory and sustainability market approaches to business's environmental responsibilities. Read each of the following questions before answering e..

  What are three benefits that the osi model offers

The TCP/IP model has been in use for years before the OSI layered model was released. Today, TCP/IP is the protocol that is used for Internet communications. However, the practicality of the TCP/IP did not make the OSI model irrelevant.

  Tcp flags are utilized

Provide a detailed description of how each of the following TCP flags are utilized: (In Network Security) SYN (Synchronize) ACK (Acknowledgement)

  What features might business owner want new website include

Compare and contrast available IT security solutions to address the needs you identified. What are the advantages and disadvantages to each interms of supporting the business owner's objectives?

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