diff --git a/tp2/Crossword.java b/tp2/Crossword.java index 4347bd4e175adf0a31745538d1056d175e6ed1f1..1fdff783d38a979fa52d790494bfdaa4b2cb75ef 100644 --- a/tp2/Crossword.java +++ b/tp2/Crossword.java @@ -147,6 +147,19 @@ public class Crossword { System.out.println(); } + public int countWord(String word){ + this.WordCount = 0; + for (int j = 0; j < columns; ++j) { + for (int i = 0; i < rows; ++i) { + if (searchRow(j, i, word)) { + this.WordCount ++; + } else if (searchColumn(j, i, word)) { + this.WordCount ++; + } + } + } + return this.WordCount; + } }