Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 please and thank you. pack of playing cards has four suits, 'H', 'D', 'S', and 'C', (Hearts, Diamonds, Spades and Clubs) and a

image text in transcribed

image text in transcribed

Python 3 please and thank you.

pack of playing cards has four suits, 'H', 'D', 'S', and 'C', (Hearts, Diamonds, Spades and Clubs) and a value through 13 making a total of 52 cards. The following symbols map to the following values: A=1,2=2,3=3. =4,5=5,6=6,7=7,8=8,9=9,10=10,J=11,Q=12,K=13 (with A being the Ace, J being the Jack, Q being the lueen and K being the King). The suit a card belongs to does not affect its value, so, 2H and 2S both have he value of 2. On the other hand, QH has a higher value of 12 compared to AH that has a value of 1. ou are required to design and implement an ADT named card. A card is a data structure that carries ut some operations on a pack of cards. Each card itself will be stored as a string. with a numeric value he card ADT has 6 operations: - Card.create () Creates and returns a list of all possible cards that can be drawn from the 52 card playing deck. That is, all possible combinations of the suits of cards ['H', 'D', 'S', 'C'] and the values 1 through 13 (but using A as 1,J as 11,Q as 12,K as 13). print(Card.create())#["AH","2H","3H","4H","5H","6H","7H","8H","9H","10H","JH","QH","KH",..]#Repeatedforthe3othersuits(D,S,C) - Card.deal (num_cards, num_players, deck) Randomly deals a number of cards to a number of players from the given deck (list of card strings). When a card is drawn, it is removed from the deck. deal() returns each player's hand as a list of lists. It is up to you to decide what happens if the deck runs out of cards before all players have been dealt all of their cards. \[ \begin{array}{l} \text { cards_dealt }=\text { Card.deal }(5,3, \text { deck) } \\ \text { print (cards_dealt) } \\ \text { \# [ ["5D" , "10H", "QS", "8C", "JH"], } \\ \text { \# ["JC", "2H", "8D" , "AS", "9C"], } \\ \text { \# ["7H", "6H", "9H", "10S", "8H"]]. } \\ \end{array} \] - Card.value (card) Takes in the string of a card, and returns its integer value. Remember, its suit does not affect its value. Also remember that A=1,J=11,Q=12,K=13. For example, Card.value("KS") returns 13. and Card.value("4D") returns 4. - Card.highest(list_of_cards) Takes a list of cards, and returns the the card string with the highest. value. For example: \[ \begin{array}{l} \text { highest_card = Card.highest ( } \left.\left[" 5 D " \text { " " } 10 H^{\prime \prime}, " Q S " \text {, "8C", "JH" } ight] ight) \\ \text { print(highest_card) \# outputs: "QS" } \end{array} \] - Card.lowest(list_of_cards) Takes a list of cards, and returns the string with the lowest value. For example: \[ \begin{array}{l} \text { lowest_card = Card.lowest (["5D" ,"10H", "QS" , "8C" ," JH" }]) \\ \text { print(lowest_card) \# outputs: "5D" } \end{array} \] - Card. average (list_of_cards) Takes a list of cards, and returns the average (float) value of this given list of cards. average=Card.average([5D","10H","QS","8C,"JH"])#illcomputetheaveragefor:5,10,12,8,11print(average)#outputs:9.2 Testing Write a test script that tests your implementation of the ADT, and ensures that all operations are correct. Think about the same kinds of issues: - White-box test cases. - Black-box test cases. - Boundary test cases, and test case equivalence classes. - Test coverage, and degrees of testing. - Unit vs. Integration testing. Running your test script on your correct ADT should report no errors, and should display nothing except the message ' Test script completed '. What to Hand In - A Python program named a4q4.py containing the ADT operations (new and modified). - A Python script named a4q4_testing.py containing your test script. Evaluation - 1 mark: Your operation create () is correct and well documented. - 1 mark: Your operation value (card) is correct and well documented. - 1 mark: Your operation deal (num_cards, num_players, deck) is correct and well documented. - 1 mark: Your operation highest (1ist_of_cards) is correct and well documented. - 1 mark: Your operation lowest (1ist_of_cards) is correct and well documented. - 1 mark: Your operation average (1ist_of_cards) is correct and well documented. - 6 marks: Your test script checks that the operations work correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions