Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
Draw a Card

Draw a card - IOmanip practice


Video Summary: https://youtu.be/eN2Z3h7Y2Yk


In this exercise, you will generate a random number between 1 and 13, and place it in a "card" made of dashes and lines (they won't line up properly, but that is fine)

You may find these IOmanipulators helpful for this:

Make sure when you draw a two-digit card the format doesn't break.

Suggested steps:

  1. Generate a top and bottom line of dashes using setw and setfill. For this to work, you will need to add "" at the end of the cout so there is something there.
  2. Generate some empty lines with border to add some spacing to the card at the top and bottom by changing setfill back to ' '
  3. Place the card value in the middle. Use setw to make sure the card doesn't break

A sample output might look like this:

------- 
|     |
|  8  |
|     |
-------

Solution