CJCoding With Joseph
15free / daySign inCreate account

Deck Of Cards

Write two classes from scratch. Card(rank, suit) stores both strings and has label() returning <rank> of <suit>. Deck() takes no arguments; its constructor creates an empty list attribute cards and fills it with two nested loops, the outer over the suits Clubs, Diamonds, Hearts, Spades in that order and the inner over the ranks 2 to 10 then J, Q, K, A, appending a Card for each pair, so the last card added is the ace of spades; deal() removes the last card with .pop() and returns it; size() returns how many cards remain. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line, a whole number, which the tests read; they print the size of a fresh deck, deal that many cards printing each label, and print the size again.

Expected Output:

52
A of Spades
K of Spades
50

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Classes
📥 Auto-Input:
2\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.