Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Config(String s, int w, int h) throws ParseException
- {
- tiles = char[w][h];
- char[] cs = s.toCharArray();
- boolean blank = false;
- if(s.length() == w*h)
- for(int i = 0; i < h; i++)
- for(int j = 0; j < w; j++) {
- char c = cs[i+j];
- if(blank && c == '_') throw new ParseException("Configuration has too many blank tiles");
- else if(c == '_') blank = true;
- else char[i][j] = c;
- }
- else throw new ParseException("Configuration wrong", x * y);
- }
Add Comment
Please, Sign In to add comment