Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Exam Question - Dice Game

Looks at an exam question. Pseudocode and testing.
by

Mark Tranter

on 28 October 2012

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Exam Question - Dice Game

Pseudocode Pseudocode is often a useful way to plan a program.
The idea is that you write something that is close to the actual code you would use, but without worrying about the more technical / language specific features.

In this example, the flow-chart helps us to quickly create some pseudocode. call dice subroutine
if dice[1] = dice[2] = dice [3]
score = sum of dice values
if two are the same
score = (sum of 2 that are the same) - other value
else
score = 0
print dice rolls
print score

dice subroutine
loop 3 times, using i as counter:
dice[i] = random number (1-6) This is a very simple program. We are going to improve it a lot. First job:
Instead of using dice1, dice2 and dice3,use a list:
dice[1], dice[2], dice[3].

Change the roll subroutine and the display section so they use loops to set up and display the list.

Test that this is working. Now, write a function to calculate the score for that round of the game.

Test that it produces the correct result. To adapt our program to help us with this question, it would be helpful to be able to directly enter trial dice-rolls and get the score.

Can you create a menu which gives this as an option?
Check the simple menu program we did last term for tips. The questions also asks us what rolls would produce negative scores.

Can you write a function that would do this for us? https://www.dropbox.com/s/gtg2n68ji2uoxg2/dice1.sb Now, read through your code carefully.

Are there parts that basically do the same thing?

Can you create a subroutine to do these?

Remember to test your program is working after you've changed something.
Full transcript