COS 100: Introduction to Programming

Interim 2021

HW Project 04: Darts game

Due: 01/13 Wed 10pm

Now a certain man drew a bow at random, and struck the king of Israel between the joints of his armor. So he said to the driver of his chariot, "Turn around and take me out of the battle, for I am wounded."
I Kings 22:34

Project goal

Create a simulation of a 301 darts game.

Project specification

Notes and hints

Suggested order of development

  1. Generate a random number and print it out.
  2. Loop 10 times and generate different random numbers for each loop iteration.
  3. Start with a score of 301, generate a random number each iteration and subtract that from your running total.
  4. Extend the loop from 10 times to as many times as needed.
  5. Add in the rest of the requirements above.

Grading rubric

Sample runs

  1. Welcome.  Initial score is 301
    Throw 1 hit the 17, score is now 284
    Throw 2 hit the 9, score is now 275
    Throw 3 hit the 16, score is now 259
    Throw 4 hit the 18, score is now 241
    Throw 5 missed. =(
    Throw 6 hit the 20, score is now 221
    Throw 7 hit the 2, score is now 219
    Throw 8 missed. =(
    Throw 9 hit the 14, score is now 205
    Throw 10 hit the 11, score is now 194
    Throw 11 hit the 9, score is now 185
    Throw 12 hit the 6, score is now 179
    Throw 13 hit the 1, score is now 178
    Throw 14 hit the 5, score is now 173
    Throw 15 hit the 11, score is now 162
    Throw 16 hit the 16, score is now 146
    Throw 17 hit the 15, score is now 131
    Throw 18 hit the 6, score is now 125
    Throw 19 hit the 7, score is now 118
    Throw 20 missed. =(
    Throw 21 hit the 17, score is now 101
    Throw 22 hit the 17, score is now 84
    Throw 23 hit the 3, score is now 81
    Throw 24 hit the 16, score is now 65
    Throw 25 hit the 11, score is now 54
    Throw 26 hit the 12, score is now 42
    Throw 27 hit the 16, score is now 26
    Throw 28 hit the 20, score is now 6
    Throw 29 hit the 9, but score is only 6, so it doesn't count.
    Throw 30 hit the 1, score is now 5
    Throw 31 hit the 15, but score is only 5, so it doesn't count.
    Throw 32 hit the 5, score is now 0
    The game is over after 32 throws.
    
  2. Welcome.  Initial score is 301
    Throw 1 missed. =(
    Throw 2 hit the 10, score is now 291
    Throw 3 hit the 16, score is now 275
    Throw 4 hit the 18, score is now 257
    Throw 5 hit the 13, score is now 244
    Throw 6 hit the 6, score is now 238
    Throw 7 hit the 10, score is now 228
    Throw 8 hit the 4, score is now 224
    Throw 9 missed. =(
    Throw 10 hit the 18, score is now 206
    Throw 11 hit the 8, score is now 198
    Throw 12 hit the 5, score is now 193
    Throw 13 hit the 1, score is now 192
    Throw 14 hit the 5, score is now 187
    Throw 15 hit the 11, score is now 176
    Throw 16 hit the 4, score is now 172
    Throw 17 hit the 9, score is now 163
    Throw 18 hit the 17, score is now 146
    Throw 19 hit the 19, score is now 127
    Throw 20 hit the 8, score is now 119
    Throw 21 hit the 20, score is now 99
    Throw 22 hit the 18, score is now 81
    Throw 23 hit the 7, score is now 74
    Throw 24 hit the 1, score is now 73
    Throw 25 hit the 19, score is now 54
    Throw 26 missed. =(
    Throw 27 hit the 4, score is now 50
    Throw 28 hit the 8, score is now 42
    Throw 29 hit the 7, score is now 35
    Throw 30 hit the 19, score is now 16
    Throw 31 hit the 10, score is now 6
    Throw 32 hit the 7, but score is only 6, so it doesn't count.
    Throw 33 missed. =(
    Throw 34 hit the 19, but score is only 6, so it doesn't count.
    Throw 35 hit the 5, score is now 1
    Throw 36 hit the 14, but score is only 1, so it doesn't count.
    Throw 37 hit the 18, but score is only 1, so it doesn't count.
    Throw 38 hit the 2, but score is only 1, so it doesn't count.
    Throw 39 hit the 17, but score is only 1, so it doesn't count.
    Throw 40 hit the 8, but score is only 1, so it doesn't count.
    Throw 41 hit the 4, but score is only 1, so it doesn't count.
    Throw 42 hit the 17, but score is only 1, so it doesn't count.
    Throw 43 hit the 13, but score is only 1, so it doesn't count.
    Throw 44 hit the 12, but score is only 1, so it doesn't count.
    Throw 45 hit the 11, but score is only 1, so it doesn't count.
    Throw 46 hit the 15, but score is only 1, so it doesn't count.
    Throw 47 hit the 16, but score is only 1, so it doesn't count.
    Throw 48 hit the 9, but score is only 1, so it doesn't count.
    Throw 49 hit the 13, but score is only 1, so it doesn't count.
    Throw 50 hit the 12, but score is only 1, so it doesn't count.
    Throw 51 hit the 15, but score is only 1, so it doesn't count.
    Throw 52 hit the 7, but score is only 1, so it doesn't count.
    Throw 53 hit the 7, but score is only 1, so it doesn't count.
    Throw 54 hit the 19, but score is only 1, so it doesn't count.
    Throw 55 hit the 3, but score is only 1, so it doesn't count.
    Throw 56 hit the 2, but score is only 1, so it doesn't count.
    Throw 57 hit the 2, but score is only 1, so it doesn't count.
    Throw 58 hit the 6, but score is only 1, so it doesn't count.
    Throw 59 hit the 9, but score is only 1, so it doesn't count.
    Throw 60 hit the 2, but score is only 1, so it doesn't count.
    Throw 61 missed. =(
    Throw 62 hit the 13, but score is only 1, so it doesn't count.
    Throw 63 hit the 3, but score is only 1, so it doesn't count.
    Throw 64 hit the 13, but score is only 1, so it doesn't count.
    Throw 65 hit the 19, but score is only 1, so it doesn't count.
    Throw 66 hit the 14, but score is only 1, so it doesn't count.
    Throw 67 hit the 4, but score is only 1, so it doesn't count.
    Throw 68 hit the 13, but score is only 1, so it doesn't count.
    Throw 69 hit the 12, but score is only 1, so it doesn't count.
    Throw 70 hit the 2, but score is only 1, so it doesn't count.
    Throw 71 missed. =(
    Throw 72 hit the 2, but score is only 1, so it doesn't count.
    Throw 73 hit the 16, but score is only 1, so it doesn't count.
    Throw 74 missed. =(
    Throw 75 hit the 12, but score is only 1, so it doesn't count.
    Throw 76 hit the 3, but score is only 1, so it doesn't count.
    Throw 77 hit the 1, score is now 0
    The game is over after 77 throws.
    

Before moving on

As an optional challenge, think about possible extensions that you can add to your program to make it more exciting. Be creative. If you would like to code up these extensions:

Start early, have fun, and discuss questions on Moodle.