I Need Help! BINGO Java program Project

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fsunka
    New Member
    • Feb 2008
    • 5

    I Need Help! BINGO Java program Project

    Hey, I have a project due around February 28. I have to create a program that asks the user for the number of players that want to play bingo. Then it creates that many bingo cards. Then it calls out BINGO numbers, but it can't make a repeat call out. Also, when something is called out, I have to somehow mark on the card that it has been called out. When the person gets 5 horizontally or vertically (not diagonally) then the programs says that player wins.

    This is my first/probably only programming class so I'm a little confused. I'm thinking a 2D array for the entire possible list with 15 rows and 5 columns... not sure how to create 2D arrays for the cards from that array without having repeats. Any tips or hints or a little help to stop repeats within each card and within the call outs?
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    One way to get random selection without repetition is to take a list and instead of repeatedly randomly selecting from the list (which might incur repetition), shuffle the list. Then simply iterate through the shuffled list -- think of shuffling a deck of playing card and going through the deck after that -- you won't see the same card twice!

    Alternately, let repetitions occur but notice this and repeat the random selection until what you choose is not a repetition.

    Comment

    • Fsunka
      New Member
      • Feb 2008
      • 5

      #3
      Originally posted by BigDaddyLH
      One way to get random selection without repetition is to take a list and instead of repeatedly randomly selecting from the list (which might incur repetition), shuffle the list. Then simply iterate through the shuffled list -- think of shuffling a deck of playing card and going through the deck after that -- you won't see the same card twice!

      Alternately, let repetitions occur but notice this and repeat the random selection until what you choose is not a repetition.
      How would I shuffle the list? Is there some code or something? I heard one of my classmates talking about putting the randomly selected call outs in a new array and somehow using that array to prevent repetitions, but I only know the logic of java rather than codes, hopefully my teacher will help tomorrow or someone here can tell me how to shuffle the list (completely so that it would call out for example: B12, N38, B7, etc. like a real bingo game) or how to put the random callouts in a new array and how that would prevent repetitions. Thanks for your help so far and luckily I have a while to work it out since we're still in the planning stages.

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Here is how I would random shuffle a pack of cards in a way that could translate to code. (Call the positions in the deck 0 to 51.)

        * Randomly choose a card in the range 0 <= c <= 51; swap that card with the one at position 51 (bottom of the deck).
        * Randomly choose a card in the range 0 <= c <= 50; swap that card with the one at position 50.
        * Randomly choose a card in the range 0 <= c <= 49; swap that card with the one at position 49
        ...
        * Randomly choose a card in the range 0 <= c <= 2; swap that card with the one at position 2
        * Randomly choose a card in the range 0 <= c <= 1; swap that card with the one at position 1
        Done!

        You've essentially drawn all the cards out of the deck in a random order, but without having to create a second data structure.

        Comment

        • Fsunka
          New Member
          • Feb 2008
          • 5

          #5
          I see how that would work for the callouts but could I use that for creating the cards? Is there a way to reset the array so it can do it for every card?

          Comment

          • Fsunka
            New Member
            • Feb 2008
            • 5

            #6
            nvm i think ill use if statements for the cards since she let us know that we can set the maximum number of players/cards to 4 so we can have definite variables.

            Comment

            • BigDaddyLH
              Recognized Expert Top Contributor
              • Dec 2007
              • 1216

              #7
              Originally posted by Fsunka
              I see how that would work for the callouts but could I use that for creating the cards? Is there a way to reset the array so it can do it for every card?
              Could you define the following:
              * What is a "callout"?
              * What do you mean by "creating the cards"?
              * What do you mean by "reset the array"?

              Comment

              • BigDaddyLH
                Recognized Expert Top Contributor
                • Dec 2007
                • 1216

                #8
                Originally posted by Fsunka
                nvm i think ill use if statements for the cards since she let us know that we can set the maximum number of players/cards to 4 so we can have definite variables.
                * What do you mean by "if statements for the cards"? How can a card be an if statement?
                * What is a "definite variable"?

                Comment

                • Fsunka
                  New Member
                  • Feb 2008
                  • 5

                  #9
                  My teacher saw this (she only read the title) and assumed our group was cheating. She accused us of getting methods/codes written by the people here, and I told her to just look at the posts and that I was just asking for hints/ideas, but she wouldn't listen.
                  I didn't think it was wrong or else I would've closed the window, but what she thinks is what counts. I guess we should've asked for her help instead, but I didn't think she would help on this project (I was wrong as I found at later when she was eager to help). Bad mistake so now we have to do a battleship project but we will NOT ask for any outside help on this new project, although thank you for your effort.

                  Comment

                  • BigDaddyLH
                    Recognized Expert Top Contributor
                    • Dec 2007
                    • 1216

                    #10
                    Originally posted by Fsunka
                    My teacher saw this (she only read the title) and assumed our group was cheating. She accused us of getting methods/codes written by the people here, and I told her to just look at the posts and that I was just asking for hints/ideas, but she wouldn't listen.
                    I didn't think it was wrong or else I would've closed the window, but what she thinks is what counts. I guess we should've asked for her help instead, but I didn't think she would help on this project (I was wrong as I found at later when she was eager to help). Bad mistake so now we have to do a battleship project but we will NOT ask for any outside help on this new project, although thank you for your effort.
                    Oh well. She should have layed out the ground rules more clearly at the beginning of the project. Good luck!

                    Comment

                    Working...