i'm relatively new to coding, i only started java this year and C++ last year, i decided i wanted to tackle minesweeper, my only issue is putting all the buttons on screen, my computer-science class uses java that's a little outdated so please excuse this,
here's my code, could someone please tell me what's wrong with it?
please note that it is nowhere near finnished
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Math.*;
/*
*Author: John Pycroft
*Date CR: 15/6/2008
*Date LM: 15/6/2008
*Name of project: Minesweeper
*/
public class Minesweeper extends Applet implements ActionListener, KeyListener
{
Button mineField[][];
int numberMine[][];
int xSize, ySize, mines;
TextField X, Y, Mines;
Button Expert, Intermediate, Easy, Submit,Restart;
Label x, y, mInes;
boolean secondTime;
public void init()
{
if(secondTime)
{
remove(x);
remove(X);
remove(y);
remove(Y);
remove(mInes);
remove(Mines);
remove(Submit);
remove(Easy);
remove(Intermediate);
remove(Expert);
Button mineField[][]=new Button[xSize][ySize];
int numberMine[][]=new int[xSize][ySize];
for(int row=0; row<mineField.length; row++)
{
for(int collum=0; collum<mineField[0].length; collum++)
{
mineField[row][collum]=new Button("");
mineField[row][collum].addActionListener(this);
add(mineField[row][collum]);
}
}
for(int i=0; i<mines; i++)
{
numberMine[(int)Math.round(Math.random()*xSize)][(int)Math.round(Math.random()*ySize)]=42;
}
}
else
{
X=new TextField(30);
Y=new TextField(30);
x=new Label("Custom X");
y=new Label("Custom Y");
mInes=new Label("Custom Mines");
Mines=new TextField(30);
Easy=new Button("Easy");
Intermediate=new Button("Intermediate");
Expert=new Button("Expert");
Submit=new Button("Custom Field");
Easy.addActionListener(this);
Intermediate.addActionListener(this);
Expert.addActionListener(this);
Submit.addActionListener(this);
add(x);
add(X);
add(y);
add(Y);
add(mInes);
add(Mines);
add(Submit);
add(Easy);
add(Intermediate);
add(Expert);
}
}
public void actionPerformed(ActionEvent e)
{
if(secondTime)
{
}
else
{
if(e.getSource()==Submit)
{
xSize=Integer.parseInt(X.getText());
ySize=Integer.parseInt(Y.getText());
mines=Integer.parseInt(Mines.getText());
secondTime=true;
init();
}
else if(e.getSource()==Expert)
{
xSize=30;
ySize=16;
mines=99;
secondTime=true;
init();
}
else if(e.getSource()==Intermediate)
{
ySize=xSize=16;
mines=40;
secondTime=true;
init();
}
else if(e.getSource()==Easy)
{
xSize=ySize=8;
mines=10;
secondTime=true;
init();
}
}
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
}
public void keyTyped(KeyEvent e)
{
}
}