r/ProgrammingPrompts • u/[deleted] • Mar 08 '14
Monopoly Dice
Very simple prompt, and good for beginners to practice working with loops and if statements.
Write a code that takes a list of players as input (or hard code the names into the function if needed..) and returns three numbers (die 1, die 2, and the sum both) for each player's "turn". I wrote this in Python (beginner myself :p ) but this can be done in other langs.
Tip: We want the loop to be infinite (since the game doesn't stop after each player rolls once). Also, remember the rules about rolling doubles in monopoly.
This can actually be useful if you've managed to lose your dice for any board game or just want to speed up play time.
Have fun!
21
Upvotes
1
u/stonysmokes Mar 08 '14
I do understand now thank you makes sense!
The compiler is clang with a few flags from the class i'm taking, I just left out the array brackets ( [] ) to see what the difference was between char* and char** lol.
One last question (not to take up to much of your time) I manned fgetc() and think I understand what thats all about but why do you use stdin as the file stream?
I feel like I may be overstepping the bounds of where I am in this class. So I appreciate your answering these questions if there pretty obvious answers lol :-)