13 Nov 2018: Array Basics
Instructions
- 
Please review the following code:
 - 
Declare an array of 10 integers.
 - 
Write a
forloop to fill the array the integers 1 through 10. - 
Write a
forloop to sum the squared elements of the array. - 
Test the result of using the
.at()member function to access the 11th element. - 
Bonus Create an array and fill it with the first 20 Fibonacci numbers.
 
15 Nov 2018: A Card Game
Overview
Blackjack is one of the most widely played casino games in the world. A player’s objective is to "beat the dealer" by getting as close as possible to 21 points without going over (face cards are worth 10 points, and aces are worth either 1 or 11).
You will be editing a project that defines a Card class, creates a deck (vector) of cards, and then randomly shuffles the deck. You will be drawing hands of cards, and assigning points to the hand.
Instructions
- 
Please review the following code:
 - 
Edit
main()to draw a hand (vector) of the top 2 cards from the "top" of the shuffled deck (top = index 0).- 
Use an integer counter to keep track of your position in the deck.
 - 
If you were playing Blackjack, how many points would your hand have?
 
 - 
 - 
"Draw" the next card from the deck, and add it to your hand with the
push_back()member function. - 
Write a function that
- 
Takes a deck (vector of cards), and returns void
 - 
First draws two cards from the top of the deck, and outputs their values to the user
 - 
Asks the user if they want to draw again (0: no, 1: yes)
 - 
If yes, draw the next card and add it to hand, and output the hand
 - 
If no, output the final hand and return
 
 - 
 
Next Steps
- 
Add a member function to the
Cardclass that returns the Blackjack value of a card (assume 11-13 score as 10, and aces score as 1). - 
Rewrite your "draw a hand" function to:
- 
Use the above member function to score the hand after each draw
 - 
Return 0 immediately when the hand score exceeds 20
 - 
Otherwise, return the hand score when the user choses to stop drawing
 
 -