Question Has Bomb


Jun 20, 2019
Programming Experience
How can I make a Boolean that has different values based on which element it is targeting, for example in minesweeper. A tile can have a bomb or not, so something like this:
if(tile1.hasBomb) {
What do you not understand about the examples you already found on the web? The general idea is that we help you to solve problems here, not write your code for you. If you try and fail then I'll be happy to help further but if I've pointed you in the right direction, I do expect that you'll try first.
All you need to learn is how to create a class and instantiate it. For example a class named Tile that contains a boolean field called HasBomb. Everytime you create a tile you instantiate a new Tile object and could add it to either a list or array or whatever you wish.
Top Bottom