proj1 bingo nums

Upload: evaldo-da-silva

Post on 05-Mar-2016

217 views

Category:

Documents


0 download

DESCRIPTION

Bingo Project

TRANSCRIPT

  • EGR 261-01 Structured Programming in C

    Programming Project #1: Bingo!

    1. Basic Description Bingo is a game of chance. Each player takes a Bingo card. Each card has 25 spaces organized into 5 columns and 5 rows under the BINGO header, as follows:

    B I N G O

    Each space has a value between 1 and 75 selected at random, except no two spaces on a card can have the same value. The allowed range of values in each column is as follows: B: 1-15, I: 16-30, N: 31-45, G: 46-60, and O: 61-75.

    Then during game play, values between 1 and 75 are selected at random, traditionally by placing numbered balls in a basket and drawing them out one at a time. Once a number is selected, it must not be selected again in the same game. If a number on a card is selected, the player covers the corresponding space on the card. In addition, the center space (the third space down in the N column) is called FREE and is always covered. A player wins the game by covering any of the following.

    1. All the spaces in any row. 2. All the spaces in any column. 3. All the spaces on either diagonal. 4. The four corner spaces.

    You can look up a more complete description on the Internet. Project Objective You are to write a C program to play the game of Bingo for two players each with one card. You must properly divide the program into functions, as appropriate. (If youre not sure what is appropriate, show your program to the instructor during development.) Do NOT use global variables. But DO use constant macros for significant parameters here; in particular you better use constant macros for the numbers 5 and 75.

  • EGR 261-01 Structured Programming in C Program flow description:

    1. Explain the game, and allow the person typing at the keyboard to exit or proceed at this point. Use

    a function to do this instead of doing it all in main(). 2. Use a 2-dimensional integer array for each Bingo card. 3. Assign a value to each space on each Bingo card. Use a function to do this. Also, use your

    function from Assignment #4 here. 4. Display each Bingo card. Use a function to do this. 5. Ask the player who will be using the first card to type their name, and ask the player who will be

    using the second card to type their name. Use a large constant macro for the maximum length of each name, and use fgets() to read each name. (If you use some utility other than fgets(), e.g. scanf(%s) or even gets(), then you may receive lower credit.)

    6. Select a value at random between 1 and 75 and display it with the appropriate letter, e.g. G-57 or B-9 . Use your function from Assignment #4 here.

    7. Ask the person typing at the keyboard to press the Enter key before doing the next steps. Say something like, or , please press the Enter key:, using the players names (e.g. Pat or Sam, please press the Enter key:).

    8. Mark appropriate spaces on each bingo card. Use a function to do this. One easy way to do this is to make a covered number negative.

    9. Display each Bingo card, showing which spaces are covered. Use a function again for this. 10. Determine if anyone has won the game. Use a function for this. If both players won, then ask

    which player yelled BINGO! first, asking for the name of the true winner to be typed. Repeatedly ask again if the name that is typed isnt either of the two players names.

    11. Repeat the preceding steps 6 through 10 until there is a winner. 12. Ask each player by name if they want to play again (except you dont need to ask the second player

    if the first player said yes), and if so, then go back to step 1. Yes, 1. Make sure the flow of the game is nice and clear. Asking for pressing Enter is an example of this. If youve completed everything specified above well, then for some extra credit, keep track of the numbers of wins and losses by each player while the program is running, and display this information following step 11. To do this, you may receive a little extra credit if you assume that the players do not change; or you may receive more extra credit if you really keep track of this information corresponding to each name. Additionally or alternatively for some extra credit, allow each player to have between 1 and 10 cards. Use three-dimensional arrays to keep track of everything. (Unfortunately, the display may not be so nice; so Im not sure that I really recommend that you try this extra credit option.) By the way, in case you might wonder, note that this project assignment does not involve structures at all.