Question: WRITE A PROGRAM IN C# that OUTPUTS A 52 CARD SHUFFLING DECK ** H = hearts, D=Diamonds, C=Clubs, S=Spades OUTPUT NEEDS TO LOOK LIKE: Deck
WRITE A PROGRAM IN C# that OUTPUTS A 52 CARD SHUFFLING DECK
** H = hearts, D=Diamonds, C=Clubs, S=Spades
OUTPUT NEEDS TO LOOK LIKE:
Deck Contains:
0:H] [1:H] [2:H] [3:H] [4:H] [5:H] [6:H] [7:H] [8:H] [9:H] [10:H] [11:H] [12:H] [0:D] [1:D] [2:D] [3:D] [4:D] [5:D] [6:D] [7:D] [8:D] [9:D] [10:D] [11:D] [12:D] [0:S] [1:S] [2:S] [3:S] [4:S] [5:S] [6:S] [7:S] [8:S] [9:S] [10:S] [11:S] [12:S] [0:C] [1:C] [2:C] [3:C] [4:C] [5:C] [6:C] [7:C] [8:C] [9:C] [10:C] [11:C] [12:C]
Drawn so far:
MENU:
1 - Draw
2 Shuffle
3 Put back
0 - Exit
(USER SELECTED) 2
SET Contains: [8:D] [2:D] [0:S] [3:H] [4:H] [4:S] [12:D] [10:S] [2:S] [10:C] [9:H] [2:C] [12:H] [0:D] [1:D] [1:C] [3:D] [4:D] [5:D] [6:H] [5:S] [0:H] [7:S] [8:S] [9:D] [12:S] [2:H] [0:C] [1:D] [6:D] [5:H] [6:S] [7:D] [8:H] [10:D] [11:H] [7:H] [11:S] [6:C] [1:S] [9:S] [11:H] [3:C] [4:C] [5:C] [3:S] [7:C] [8:C] [9:C] [10:H] [11:C] [12:C]
Drawn so far:
MENU:
1 - Draw
2 Shuffle
3 Put back
0 - Exit
(USER SELECTED) 1
Drew card [12:C]
Deck Contains: [8:D] [2:D] [0:S] [3:H] [4:H] [4:S] [12:D] [10:S] [2:S] [10:C] [9:H] [2:C] [12:H] [0:D] [1:D] [1:C] [3:D] [4:D] [5:D] [6:H] [5:S] [0:H] [7:S] [8:S] [9:D] [12:S] [2:H] [0:C] [1:D] [6:D] [5:H] [6:S] [7:D] [8:H] [10:D] [11:H] [7:H] [11:S] [6:C] [1:S] [9:S] [11:H] [3:C] [4:C] [5:C] [3:S] [7:C] [8:C] [9:C] [10:H] [11:C]
Drawn so far: [12:C]
MENU:
1 - Draw
2 Shuffle
3 Put back
0 - Exit
(USER SELECTED) 1
Drew card [11:C]
Deck Contains: [8:D] [2:D] [0:S] [3:H] [4:H] [4:S] [12:D] [10:S] [2:S] [10:C] [9:H] [2:C] [12:H] [0:D] [1:D] [1:C] [3:D] [4:D] [5:D] [6:H] [5:S] [0:H] [7:S] [8:S] [9:D] [12:S] [2:H] [0:C] [1:D] [6:D] [5:H] [6:S] [7:D] [8:H] [10:D] [11:H] [7:H] [11:S] [6:C] [1:S] [9:S] [11:H] [3:C] [4:C] [5:C] [3:S] [7:C] [8:C] [9:C] [10:H]
Drawn so far: [12:C] [11:C]
MENU:
1 - Draw
2 Shuffle
3 Put back
0 - Exit
(USER SELECTED) 3
Put back [11:C]
Deck Contains: [8:D] [2:D] [0:S] [3:H] [4:H] [4:S] [12:D] [10:S] [2:S] [10:C] [9:H] [2:C] [12:H] [0:D] [1:D] [1:C] [3:D] [4:D] [5:D] [6:H] [5:S] [0:H] [7:S] [8:S] [9:D] [12:S] [2:H] [0:C] [1:D] [6:D] [5:H] [6:S] [7:D] [8:H] [10:D] [11:H] [7:H] [11:S] [6:C] [1:S] [9:S] [11:H] [3:C] [4:C] [5:C] [3:S] [7:C] [8:C] [9:C] [10:H] [11:C]
Drawn so far: [12:C]
MENU:
1 - Draw
2 Shuffle
3 Put back
0 - Exit
Classes that are imperative:
-Assignment (the Main Class) shows the Card and Deck functions
-Cards A full fifty two card set
-Deck Pack of of said Playing hand
First:
Build the Cards class
-The Values: Integer (INT)
-The suits: Characters (CHAR)
-The cards that are faced up: (BOOLEAN)
Playing Hand Methods:
-CONSTRUCTORS: Cards (VALUES:INT, SUIT:CHAR)
-The Getters for the values and the suits:(CARDS CANNOT BE CHANGED AFTER YOU BUILD THEM, SO DO NOT HAVE SETTERS)
-Getters/Setters for the cards that are faced up: Can be flipped over -
toString Method: Must be overridden so that the playing hands are printed
SECOND: Build the Deck Class Set Properties:
-Deck: Cards []
-cardsCount: INT (Records the # of cards in array)
-maximumSize: Int (allows initialization of array)
Deck Methods: Constructors:
-Deck() (Filled with the deck of the fifty two playing hand and make this private method to help fill the set)
-Deck(size:int) (Set the maximumSize to the value to be passed in, must initialise the array, but dont fill it, and use this constructor to create a empty set to be filled through the Add() method) -Shuffle(): void (Shuffles said array)
-Draw:Cards (reduces the playing hand count and returns the playing hand object reference)
-Add(newCards:Cards) (takes a playing hand reference and adds it to array if possible)
-PrintDeck (to display the array in an orderly fashion, cards.toString())
Finally:
Make a basic UI to test the set in isolation Show what the set has and provide user the ability to shuffle set, draw a card, put the last card back into the Deck, or exit menu. Draw Option will call the Set Draw Method, shuffle calls on shuffle method, put back into Deck will take last playing hand drawn from the Deck and put that back into Deck using the set Add method
The Drawn seen here was using a 2nd set object instead of standalone array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
