Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am stuck on creating it with only one array. I am currently: Tiles.java--- imp

ID: 3635698 • Letter: I

Question

I am stuck on creating it with only one array. I am currently:


Tiles.java---
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JPanel;

public class tiles extends JPanel implements MouseListener
{
public tiles()
{

}

int numAdjacent;
private void set numberAdjacentTiles(){


}
private boolean mines(){

return isIt;
}
boolean isIt
private void placeMines(boom boolean){
isIT=boom

}
private void reveal (clicked boolean){

if (mines() == true)
{
initGame.gameOver();
}
else{
gameWon();
}

}
int gameMines;
private int mineCounter(mines int){
gameMines=mines;
}



----

initGame.java

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JPanel;

public class initGame extends JPanel implements MouseListener
{
public initGame()
{
Grid();
JButton enterButton = new JButton( "Press to Start" );

// add an action listener for button's action (click)
enterButton.addActionListener(
// this is a way of mimicking Function passing in AS3
new ActionListener()
{
/**
* Invoked when associated action is performed.
**/
public void actionPerformed( ActionEvent e )
{
// this is where you put the code you want
// executed when the button is pressed
// here, we call a method to update the display
resetTiles();

}});


}

private int numberTilesAdjacent(){



}
public Grid()
{

// Grid Boxes
setLayout( new GridLayout( 10, 10 ) );
new Tiles[10][10]

for( int i = 0; i < 10 && i < 10; i++ )
{
addCard( rows[i], columns[i] );
}

private void resetTiles();{
getMines();
getTiles();
}

private void placeMines(int mines);{
for (int i =0; i < mines; i++){
Random a = new Random();
int rowNum = a.nextInt(100);
Random b = new Random();
int colNum = b.nextInt(100);
[rowNum][colNum].placeMines(true);

}


}
private void getMines();
{
Random generator = new Random();
// Get the next integer between 0 and 20.
int randomNumber = generator.nextInt(30);
numberMines=randomNumber
Tiles.mineCounter(numberMines);

placeMines(numberMines);
}
private void gameOver();
{

}
private boolean bounds();
{
if ( Tiles[1]|| Tiles[2]|| Tiles[3]|| Tiles[4]|| Tiles[5]|| Tiles[6]|| Tiles[7]|| Tiles[8]|| Tiles[9]|| Tiles[10]){
return true
}
else if( Tiles[0][1]|| Tiles[0][2]|| Tiles[0][3]|| Tiles[0][4]|| Tiles[0][5]|| Tiles[0][6]|| Tiles[0][7]|| Tiles[0][8]|| Tiles[0][9]|| Tiles[0][10]){
return true
}
else{
return false
}
}
int totalTiles;
private void countClicks(){
totalTiles= totalTiles + 1

}
private void gameWon(){
if( 100-totalTiles == numberMines)
{
return ();
}
}
public static void Grid( String[] args )
{
Grid();
initGame();
}
}
}


Explanation / Answer

import java.awt.* ; import java.awt.event.* ; import java.awt.geom.* ; import javax.swing.* ; import javax.swing.event.* ; /**MineSweeper by SciWizEH*/ public class MineSweeper extends JFrame implements ActionListener , MouseListener { int rows = 10 ; int cols = 10 ; int numMines = 10 ; GridLayout layout = new GridLayout ( rows , cols ) ; /*type[][] name = new type[rows][cols]; * type[x][y]; * is 1d * type[] name = new type[rows*cols]; * type[(rows*y)+x];*/ boolean [ ] mines = new boolean [ rows * cols ] ; boolean [ ] clickable = new boolean [ rows * cols ] ; boolean lost = false ; boolean won = false ; int [ ] numbers = new int [ rows * cols ] ; JButton [ ] buttons = new JButton [ rows * cols ] ; boolean [ ] clickdone = new boolean [ rows * cols ] ; JMenuItem newGameButton = new JMenuItem ( "new game" ) ; JMenuItem difficulty = new JMenuItem ( "options" ) ; JLabel mineLabel = new JLabel ( "mines: " + numMines + " marked: 0" ) ; JPanel p = new JPanel ( ) ; public MineSweeper ( ) { p.setLayout ( layout ) ; setupI ( ) ; for ( int i = 0 ; i < ( rows * cols ) ; i ++ ) { p.add ( buttons [ i ] ) ; } JMenuBar mb = new JMenuBar ( ) ; JMenu m = new JMenu ( "file" ) ; newGameButton.addActionListener ( this ) ; m.add ( newGameButton ) ; difficulty.addActionListener ( this ) ; m.add ( difficulty ) ; mb.add ( m ) ; this.setJMenuBar ( mb ) ; this.add ( p ) ; this.add ( mineLabel , BorderLayout.SOUTH ) ; this.pack ( ) ; this.setVisible ( true ) ; } public void fillMines ( ) { int needed = numMines ; while ( needed > 0 ) { int x = ( int ) Math.floor ( Math.random ( ) * rows ) ; int y = ( int ) Math.floor ( Math.random ( ) * cols ) ; if ( ! mines [ ( rows * y ) + x ] ) { mines [ ( rows * y ) + x ] = true ; needed -- ; } } } public void fillNumbers ( ) { for ( int x = 0 ; x
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote