I would like to solicit your thoughts and ideas (code can come later) about how you would approach a project idea I just tossed together. I chose this as a testbed for me to play with objects, specifically multiple instances of a few specific objects, and as I thought about it, it raised a lot of questions about how to manage, contain, signal all of those objects that do almost the same thing at the same time.
I want to build an OO bingo simulator. While it is not necessarily the most efficient approach, let's academically assume it needs to be object-oriented.
We have 75 ball objects, which can be picked randomly by a machine, and which therefore need an awareness of being picked(), since no ball can come up twice in a game.
We have a scorecard grid with 25 square objects on it, and appropriate values for each column of the grid (B: 1-15,i:16-30, etc.), which are chosen randomly on each card. If we work with all 75 possible numbers (maybe not the best approach), each number needs to know if it's on the bingo card for this game, whether it's matched a number that's already been picked(), and whether it's a Freebie (middle square on the card - 'FREE' instead of a number)
Initial questions:
Can like objects be grouped by some mechanism such that changing an external parameter has them respond to that change, or do they each need to be iterated/manipulated each time to become "aware" of global changes? For example, a number is picked() - can the squares "know" if one matches the new number, or do I need to trigger each one to check?
Maybe I'm thinking in more of a parallel-thread mode here, one thread per object, which remains "active" during the game. Is that way out there? It's probably over my head at this point anyway.
Reel me in; tell me what you think.
I want to build an OO bingo simulator. While it is not necessarily the most efficient approach, let's academically assume it needs to be object-oriented.
We have 75 ball objects, which can be picked randomly by a machine, and which therefore need an awareness of being picked(), since no ball can come up twice in a game.
We have a scorecard grid with 25 square objects on it, and appropriate values for each column of the grid (B: 1-15,i:16-30, etc.), which are chosen randomly on each card. If we work with all 75 possible numbers (maybe not the best approach), each number needs to know if it's on the bingo card for this game, whether it's matched a number that's already been picked(), and whether it's a Freebie (middle square on the card - 'FREE' instead of a number)
Initial questions:
Can like objects be grouped by some mechanism such that changing an external parameter has them respond to that change, or do they each need to be iterated/manipulated each time to become "aware" of global changes? For example, a number is picked() - can the squares "know" if one matches the new number, or do I need to trigger each one to check?
Maybe I'm thinking in more of a parallel-thread mode here, one thread per object, which remains "active" during the game. Is that way out there? It's probably over my head at this point anyway.
Reel me in; tell me what you think.
Comment