Vous êtes sur la page 1sur 4

Soit la portion de la classe Sudoku dfinie

ci-dessous :

The portion of the class Sudoku defined below:


/* classe */ public class Sudoku extends Thread{ int lagrille[][]; int n; int int lesplacements=0; lacomplexite=0; tableaufinal; Sudoku

int[][] }

Question 1
Compltez le constructeur ci-dessous en implmentant la fonction initialisation ()

Fill the manufacturer below implements the initialization function

/*constructeur public

*/

Sudoku(int n){

this.n=n; lagrille=new int[n][n];

/*La fonction initialisation permet dinitialiser lagrille, lesplacements et lacomplexite

les attributs suivants :

Initialization function initializes the following attributes: lacomplexite * /


*/ initialisation } ();

lagrille, and lesplacements

Question 2
Vous devez implmenter toutes les fonctions qui permettent de renvoyer ou de dfinir les attributs de la classe Sudoku. Ces fonctions commencent par les mots clefs get pour celles qui renvoient un attribut et set pour celles qui dfinissent un attribut.

You must implement all functions to return or set the attributes of the class Sudoku. These functions start with the keywords to get those referring to an attribute set and those that define an attribute.

public int getComplexite() { complter} public int[][] getGrille() { complter} public void setGrille(int i, int j, int unedonnee) { complter} public int getN () { complter} public void setN(int n) { complter } public int getPlacements() { complter } public void setPlacements(int lesplacements) { complter } public void setTableaufinal(int[][] tableaufinal) { complter} public void setGrille(int[][] grille) { complter} public int[][] getTableaufinal() { complter }

Question 3
crivez une fonction qui retourne un boolean et qui permet de vrifier si une grille est remplie ou non. Le nom qui sera donn cette fonction grilleremplie(). Vous devez galement soumettre lalgorithme de cette fonction. /* complter */grilleremplie() { complter}

Write a function that returns a boolean and can check if a grid is filled or not. The name to be given to this function grilleremplie (). You must also submit the algorithm of this function.

Question 4
crivez une fonction appele clonage qui permet de cloner un tableau dentiers deux dimensions. Cette fonction prend comme argument un tableau dentiers deux dimensions et retourne un autre tableau dentiers deux dimensions. Vous devez galement soumettre lalgorithme de cette fonction.

Write a function called cloning can clone an array of integers in two dimensions. This function takes as argument an array of integers and returns a two dimensional array of integers other two dimensions. You must also submit the algorithm of this function.

Question 5
crivez une fonction appele affichier qui prend comme paramtre un tableau deux dimensions et qui affiche tous ses lments. Vous devez galement soumettre lalgorithme de cette fonction.

Write a function called affichier which takes as a parameter a twodimensional array and displays it entirely. You must also submit the algorithm of this function

Question 6
Expliquez ce que fait cette fonction. Vous devez corriger toutes les erreurs

Explain this function. You must correct all errors


public String for(int for(int String ecrire(){ temp=""; i=0;i<grille.length;i++){ e=0;e<grille[i].length;e++){

Temp+=Integer.toString(grille[i][e]); } } temp+=" // return Temp; } "+Integer.toString(lacomplexite);

Question 7
Expliquez et donnez les algorithmes des trois fonctions suivantes

Explain and give algorithms for the following three functions

Fonction 1 :
public boolean chercherchiffrequadran(int chiffre, int[] tab){ boolean int int int int test=true; quadran, int[][]

lignedebut=quadran[0]; colonnedebut=quadran[1]; lignefin=quadran[2]; colonnefin=quadran[3]; IL Y A EGALITE DANS LES BOUCLES

//ATTENTION for(int

ligne=lignedebut;ligne<=lignefin;ligne++){ for(int //MEME colonne=colonnedebut;colonne<=colonnefin;colonne++){ CHIFFRE DANS LE QUADRAN DONC FAUx

if(tab[ligne][colonne]==chiffre){ test=false; break; }

} }

return }

test;

Fonction 2 :
private boolean cherchequadran(int ligne, int colonne, chiffre) { int[] quadran=quadran(ligne,colonne); quadran, tab)){ int[][] tab, int

if(chercherchiffrequadran(chiffre, return true; } else{ return false; } }

Fonction 3 :
private boolean cherchedg(int ligne, int colonne, int[][] boolean test=true; tab, int chiffre) {

for(int

index=0;index<n;index++){ if((colonne+index)<n){ if (tab[ligne][colonne+index]==chiffre){ test=false; break; } }

if((colonne-index)>=0){ if(tab[ligne][colonne-index]==chiffre){ test=false; break; } } } test;

return

Vous aimerez peut-être aussi