Closed AbtaheeAli closed 4 years ago
Great work, in the future place a blank line before these lines. We should treat different sections of our code like paragraphs in written work.
Your homework 01 - 03 - All Cards On Deck was marked: Meets Expectations
“Well done!” — via Gavin Stark
In this project, you will use C# to model a deck of playing cards. You'll also add functionality such as shuffling and dealing.
Shuffling Cards
As we have seen, computers do exactly what we tell them to do. Thus, computers are bad at generating truly random numbers. Randomness is a deep and complex topic, but it's worth pointing out that most random numbers we use in computing are what we call "pseudorandom". That is, they generate numbers that appear to be random such that guessing the next random number the computer's fixed algorithm is going to generate is very difficult. This makes it good enough for most purposes. For this assignment, you will read about, then implement, a popular algorithm that shuffles the order of a finite set using C#'s built-in
Random.Next()
function as a pseudorandom number generator.Objectives
Requirements
You will model these in code, in any way you see fit. It may require you to experiment and try several techniques. There are many valid solutions.
To shuffle the cards, you should implement the Fisher–Yates shuffle algorithm. The shuffling algorithm starts with the last element in our collection (in our case a deck of cards) and swaps it with a randomly selected element that comes before it. This continues downward through the elements towards the first element. Watch the first few minutes of this video for a visual description of the algorithm.
If we were going to write an algorithm for this we would write something like:
hint: understand the algorithm before you try to implement it.
Explorer Mode
Adventure Mode
playerHand
. Consider what type of variableplayerHand
will have to be.Epic Mode
Resources