Question: Python Lab: Casino Night: Part 1: Cards In this lab you will be creating a set of classes that model objects you might find used

Python

Lab: Casino Night: Part 1: Cards

In this lab you will be creating a set of classes that model objects you might find used in a casino. The first of these classes is the Card class, representing a standard playing card from a 52 card deck. Once we have these classes, we can use them in the future to make casino games much easier. Cards will have the ability to be hidden, and information about the card will be easy to extract. Each of these method implementations should be short, and some methods can be easily implemented by calling other methods on the same object.

Note: These requirements must be met without using any while loops or for loops.

Note: The strings Ace, King, Queen, Jack, Spades, Hearts, Clubs and Diamonds may only appear once in the lab.

__init__(card_num)

The __init__() method always contains code that runs when an object is created (or initialized). This is a good place to store initial values. You may add to this method as needed later in the assignment, as you decide you need additional variables to work with. This method accepts a card_num parameter indicating which of the 52 cards we mean to create. This method will need to set one or more instance variables (e.g., suit, and rank) to record which card is being represented in this specific card object.

get_suit()

This method returns the suit of the card as a string, and should contain Spades, Hearts, Clubs or Diamonds depending on the card.

return

This method should return a string containing the name of the suit. Example: Diamonds or Spades.

get_rank()

This method returns the rank of the card as a string, and should contain Ace, Jack, Queen, King or the number of the card.

return

This method should return a string containing the rank of the card. Either a number or title. Example: 7 or King.

get_value()

This method returns a numeric value depending on the point value of the card at hand. Face cards have a value of 10, Aces are valued at 11 and other cards are valued at their numeric rank.

return

This method should return a numeric value for the card. Example: 7 or 10

face_down()

This method flips the card face-down, as cards are initialized they should be face down by default. The class variable set by this method should be accessible in the __str__() method. This method has no parameters or return values.

face_up()

This method does the opposite of face_down(). If a card is hidden and you call face_up() it should no longer be hidden. The class variable set by this method should be accessible in the __str__() method. This method has no parameters or return values.

__str__()

This method returns the card in string representation if the card is face-up. example: King of Hearts or 4 of Clubs. If the card is face-down, it should return no matter what card it is.

return

Should return a string representing the full name of the card. Example: 7 of Diamonds or King of Spades

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!