私はJAVAで初めてです。これをどのように始めるべきか分かりません。私は良いスタートを探していた。私は特定の形式を持つtxtファイルを読んで、それをビューに入れる必要があります。私は最初にグリッドの寸法を読んでから、パズルの順番で単語を見つけてから、見つけなければならない単語の量を求め、実際の単語を最後に読む必要があります。誰かが私を模範にして正しい方向へ向けることができれば、それは本当に助けになるでしょう。 これはEDIT クロスワードパズルのtxtファイルを読む
5 5
abcd
dfad
adfe
lkjl
ekkf
5
realword
realword
realword
realword
realword
txtファイルの形式である:これは私が(!ありがとう)の作品ファイルを読み出すためにテストした後しようとしたものです。しかし、私はここでstukを得る、私はまだ文字のグリッドを埋めるために必要なので、私はまだchar [] []からbox [] []に変更する必要があります。
私はちょうどあなたがテキストファイルから行を読み込む方法についてヒントを与える:
import java.io.*;
import java.util.List;
public class Puzzle {
//Box[][] letterGrid;
char[][] letterGrid;
List<Word> wordList;
List<Box> wordInWording;
public Puzzle() {
try {
BufferedReader br = new BufferedReader(new FileReader("..\\word.txt"));
String[] dimensions = br.readLine().split(" ");
letterGrid = new char[Integer.parseInt(dimensions[0])][Integer.parseInt(dimensions[1])];
for (int i = 0; i < letterGrid[0].length; i++) {
String val = br.readLine();
letterGrid[i]= val.toCharArray();
}
//while something something
int r = br.read();
int c = br.read();
letterGrid = new char[r][c];
for (int i = 0; i<r; i++){
String getChar = new String(br.readLine());
for(int j=0; j<c; j++){
letterGrid[i][j] = getChar.charAt(j);
}
}
// String sCurrentLine;
// while ((sCurrentLine = br.readLine()) != null) {
// System.out.println(sCurrentLine);
// }
} catch (IOException e) {
e.printStackTrace();
}
}
}
私は何かを追加しましたが、intsの背後に論理があり、次に文字列intとその後の文字列を得ることができませんでした –