Java.lang.NoSuchMethodError: main Exception in thread "main"
ssoouummaayyaa
Messages postés13Date d'inscriptionvendredi 5 février 2010StatutMembreDernière intervention 3 juin 2013
-
8 août 2010 à 15:30
cs_DARKSIDIOUS
Messages postés15814Date d'inscriptionjeudi 8 août 2002StatutMembreDernière intervention 4 mars 2013
-
8 août 2010 à 18:36
Bonjour ;
j'ai un problème avec mon code source : le code consiste à un interface graphique du jeu Sudoku . je n'arrive pas à repérer le problème , quelqu'un peut m'aider S.V.P
voilà le code source de l'interface
package game;
public int newGame()
{
do
game = new Sudoku(0);
while( ! game.backTrack());
displayGame();
return 1;
}
/****************************************/
public void load()
{
FileDialog fd = new FileDialog(this, "Load File", FileDialog.LOAD);
fd.setVisible(true);
String filename = fd.getFile();
try
{
File file = new File(filename);
if (file.exists())
{
DataInputStream is = new DataInputStream(new FileInputStream(filename));
int i=0;
int c;
while( (c = is.read()) != -1)
{
switch( (char) c)
{
/* fixed value */
case '-' :
{
game.fixe[i] = true;
c = is.read();
game.values[i] = c -48;
i++;
}
break;
case '\n' :
break;
case '\t':
break;
/* value entered during a previous session */
default:
{
game.fixe[i] = false;
game.values[i] = c -48;
i++;
}
break;
}
}
if(game.backTrack())
displayGame();
else
System.out.println("Sorry, no solution for the loaded grid");
is.close();
}
}
catch (Exception e) {}
}
/* to implement the moves between cells */
private class EntryListener implements KeyListener
{
private int x;
private int y;
public EntryListener(int x, int y)
{
this.x = x;
this.y = y;
}
/* Handle the key pressed event from the text field. */
public void keyPressed(KeyEvent e)
{
int key = e.getKeyCode();
switch(key)
{
case KeyEvent.VK_DOWN:
{
if(x<9)
Entries[(x+1)*9+y].requestFocusInWindow();
break;
}
case KeyEvent.VK_UP:
{
if(x>0)
Entries[(x-1)*9+y].requestFocusInWindow();
break;
}
case KeyEvent.VK_LEFT:
{
if(y>0)
Entries[x*9+y-1].requestFocusInWindow();
break;
}
case KeyEvent.VK_RIGHT:
{
if(y<9)
Entries[x*9+y+1].requestFocusInWindow();
break;
}
}
}
/* Handle the key typed event from the text field. */
public void keyTyped(KeyEvent e)
{
int id = e.getID();
if (id == KeyEvent.KEY_TYPED)
{
char c = e.getKeyChar();
if( (int)c >= 49 && (int)c <= 57 )
if( game.noConflict(x*9+y, (int)c - 48 ))
Entries[x*9+y].setText(""+c);
}
/* to stop treating of the event */
e.consume();
}
/* Handle the key released event from the text field. */
public void keyReleased(KeyEvent e) {}
}
/* to define the action to perform when clicking a button */
public void actionPerformed(ActionEvent evt)
{
Object b_quit;
if(evt.getSource() == b_quit)
{
System.exit(0);
return;
}
public boolean noConflict( int n, int value)
{
int i = n / 9;
int j = n % 9;
for(int k=0; k<9; k++)
{
/* teste la ligne (on itere sur les colonnes) */
if (k !j && this.values[i*9+k] value)
return false;
/* teste la colonne (on itere sur les lignes) */
if (k !i && values[k*9+j] value)
return false;
}
for( int l = i/3*3; l < i/3*3+3; l++)
for(int m = j/3*3; m < j/3*3+3; m++)
if (l!=i && m!=j && this.values[l*9+m] == value)
return false;
return true;
}
public boolean noConflictSol( int n, int value)
{
int i = n / 9;
int j = n % 9;
for(int k=0; k<9; k++)
{
/* teste la ligne (on itere sur les colonnes) */
if (k !j && solution[i*9+k] value)
return false;
/* teste la colonne (on itere sur les lignes) */
if (k !i && solution[k*9+j] value)
return false;
}
for( int l = i/3*3; l < i/3*3+3; l++)
for(int m = j/3*3; m < j/3*3+3; m++)
if (l!=i && m!=j && solution[l*9+m] == value)
return false;
return true;
}
/* returns false if no solution has been found
* returns true if a solution has been found
*/
public boolean backTrack()
{
int i;
for( i=0; i<81; solution[i] = values[i++] );
i = 0;
while(i<=80)
{
if(fixe[i])
i++;
else
{
if(solution[i] == 0)
solution[i] = 1;
else
solution[i] = solution[i]+1;