Guest User

Untitled

a guest
Jun 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public Config(String s, int w, int h) throws ParseException
  2. {
  3.     tiles = char[w][h];
  4.     char[] cs = s.toCharArray();
  5.     boolean blank = false;
  6.     if(s.length() == w*h)
  7.     for(int i = 0; i < h; i++)
  8.         for(int j = 0; j < w; j++) {
  9.             char c = cs[i+j];
  10.             if(blank && c == '_') throw new ParseException("Configuration has too many blank tiles");
  11.             else if(c == '_') blank = true;
  12.             else char[i][j] = c;
  13.             }
  14.     else throw new ParseException("Configuration wrong", x * y);
  15. }
Add Comment
Please, Sign In to add comment