Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Best Practices to Follow:
It’s worth breaking up each functional task in create_blackjack_game() into separate functions. For example, a function to check the score of a player’s hand, to check whether a player has won, and so on. This entire implementation can be done neatly in about eight functions.
Create a Deck of Cards
Complete the create_standard_deck() function, which creates a new deck. The deck itself must be a data structure list. The cards within the deck must be represented as tuples of the form (suit, number), where the suit is a string that must be either ‘hearts’, ‘clubs’, ‘spades’, or ‘diamonds’, and the number is an integer that must be one of the following: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, or 14. Note that the number used to identify the card has the following association: Jack = 11, Queen = 12, King = 13, and Ace = 14. In terms of value, the picture cards (Jack, Queen, and King) all have a value of 10, and the Ace card has a value of 11. The casino only wants you to implement a simple implementation of blackjack, in that the first to 21 wins, and special cases for checking for blackjack are not required. The deck should be sorted in alphabetical order of the suit, and then by an ascending integer identifier; for example: [(‘clubs’, 2), (‘clubs’, 3), ..., (‘diamonds’, 2), ..., (‘diamonds’, 14), (‘hearts’, 2), ... , (‘spades’, 14)].
Task
Implement the create_deck() function to create the deck of cards.
Drawing a Card from a Deck
Your task is to complete the function stub draw_card(deck). The function takes a deck as the input. The function should randomly select a card from the deck using the random.choice() method and then remove the card from the deck by completing the remove_card_from_the_deck() function. Once this is done, the function needs to return the card that was selected.
Task
Implement the draw_card() function which deals cards to the dealer and players and removes the corresponding card from the deck.
Getting the Count of the Cards in a Player’s Hands
Your task is to complete the function stub get_count(player). The function takes a player’s hand, which is a list, as input. The function calculates and returns the value of the player’s hand. It should be noted that a special mapping is required. Currently, in the deck, Jack has a value of 11, Queen has a value of 12, King has a value of 13, and Ace has a value of 14. You need to ensure that the Jack, Queen, and King cards all have a value of 10. Finally, for the purposes of this implementation, we will only treat the Ace with a value of 11.
Task
Implement the `get_count` function to calculate the value of cards in a player's hand.
Checking whether a Player has Won
Your task is to complete the function stub check_cards(player). The function takes a player’s hand as input and returns ‘WIN’ if the input player has exactly a count of 21. If they have a count that is greater than 21, then it returns ‘BUST’; otherwise, it returns ‘OK’.
Task
Implement the check_cards() function to check if the player has won, lost, or has room to hit.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Part 3: JavaScript - Program Outline, Startup Function, and Prompt We are going to use a function that we can consider an entry point into our running JavaScript. Below is an outline of the major elements in our JavaScript file. getRandomInt() function: generate a random integer startup() function: entry point function call to startup() function Below is your startup code: function getRandomInt(min, max) {}function startup() {}startup(); >> Add the above code components to your cis111-07.js JavaScript file below your multiline comment. >> Copy the getRandomInt function code from your previous assignment, or from this Stackoverflow article (Links to an external site.). Remember to add a single line comment above the getRandomInt function that documents the source of the code. Before attempting to use the prompt function in your code, you should try out the function in the console. >> Enter the following into the console to test displaying the prompt dialog. prompt();…arrow_forwardFocus on dictionary methods, use of functions, and good programming styleFor this assignment, you will create a glossary (dictionary) of technical terms and definitions. It will be set up as a Python dictionary structure. The file glossary_starter.py is a complete starter framework for the assignment. It includes some initial values for the dictionary. It is long because most of the code has already been written for you.Your task is to complete the five individual functions for adding and deleting terms, looking up terms, listing them, and printing out both the terms and definitions. These functions are all short, just a couple of lines, and use basic dictionary methods and techniques. Here is some sample output. Glossary system 1) Add a term 2) List terms 3) Get a definition 4) Delete a term 5) Print out dictionary 6) Quit Enter your choice: 2 argument dictionary hashmap list set 5 terms Glossary system 1) Add a term 2) List terms 3) Get a definition 4) Delete a term 5) Print…arrow_forwardIn this task you will work with the linked list of digits we have created in the lessons up to this point. As before you are provided with some code that you should not modify: A structure definition for the storage of each digit's information. A main() function to test your code. The functions createDigit(), append(), printNumber(), freeNumber(), readNumber() and divisibleByThree() (although you may not need to use all of these). Your task is to write a new function changeThrees() which takes as input a pointer that holds the address of the start of a linked list of digits. Your function should change all of those digits in this linked list that equal 3 to the digit 9, and count how many replacements were made. The function should return this number of replacements. Provided codearrow_forward
- Every data structure that we use in computer science has its weaknesses and strengthsHaving a full understanding of each will help make us better programmers!For this experiment, let's work with STL vectors and STL dequesFull requirements descriptions are found in the source code file Part 1Work with inserting elements at the front of a vector and a deque (30%) Part 2Work with inserting elements at the back of a vector and a deque (30%) Part 3Work with inserting elements in the middle, and removing elements from, a vector and a deque (40%) Please make sure to put your code specifically where it is asked for, and no where elseDo not modify any of the code you already see in the template file This C++ source code file is required to complete this problemarrow_forwardPlease just use main.cpp,sequence.cpp and sequence.h. It has provided the sample insert()function. No documentation (commenting) is required for this assignment. This assignment is based on an assignment from "Data Structures and Other Objects Using C++" by Michael Main and Walter Savitch. Use linked lists to implement a Sequence class that stores int values. Specification The specification of the class is below. There are 9 member functions (not counting the big 3) and 2 types to define. The idea behind this class is that there will be an internal iterator, i.e., an iterator that the client cannot access, but that the class itself manages. For example, if we have a Sequence object named s, we would use s.start() to set the iterator to the beginning of the list, and s.advance() to move the iterator to the next node in the list. (I'm making the analogy to iterators as a way to help you understand the point of what we are doing. If trying to think in terms of iterators is confusing,…arrow_forwardIn python don't import librariesarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education