diff --git a/tp2/Crossword.java b/tp2/Crossword.java index 5b1263c882b0e92c73b9bbb6ed6919314154dd5f..a0e13795cb91b73b4f1ceec2c4fe86c82079f3d3 100644 --- a/tp2/Crossword.java +++ b/tp2/Crossword.java @@ -27,12 +27,11 @@ public class Crossword // Code pour calculer la taille du tableau et initialiser les variables d'instance "rows" et "columns" Scanner scan = new Scanner(file); - rows = 0; List<String> stringrow = new ArrayList<>(); while (scan.hasNextLine()){ - rows++; stringrow.add(scan.nextLine()); } + rows = stringrow.size(); columns = stringrow.get(0).length(); // Code pour créer le tableau "array" @@ -103,7 +102,7 @@ public class Crossword private boolean searchRow(int y, int x, String word) { boolean f = true; - if (word.length() + x >= this.columns) { + if (word.length() + x > this.columns) { return false; } @@ -119,7 +118,7 @@ public class Crossword private boolean searchDia(int y, int x, String word) { boolean f = true; - if ((word.length() + x >= this.columns)||(word.length() + y >= this.rows)) { + if ((word.length() + x > this.columns)||(word.length() + y > this.rows)) { return false; } @@ -137,7 +136,7 @@ public class Crossword private boolean searchColumn(int y, int x, String word) { boolean f = true; - if (word.length() + y >= this.rows) { + if (word.length() + y > this.rows) { return false; } diff --git a/tp2/Main.java b/tp2/Main.java index 3b594d17032260ceb3d0d3f952e8db29e94dacff..ef04caf63c4f0e5f18c3a44bc2920e80f6aa49eb 100644 --- a/tp2/Main.java +++ b/tp2/Main.java @@ -24,7 +24,6 @@ public class Main { while (mot != "stop"){ mot = mot.toUpperCase(); tableau.search(mot); - System.out.println(tableau.countWord(mot)); mot = scan.nextLine(); }