Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public void setBoard(String input) {
  2.  
  3. String replaceinput = input.replaceAll("\\.", "0");
  4. int charcount = 0;
  5. for (int i = 0, len = replaceinput.length(); i < len; i++) {
  6. if (Character.isDigit(replaceinput.charAt(i))) {
  7. charcount++;
  8. }
  9. }
  10. if (charcount != 81) {
  11. throw new IllegalArgumentException("Din string är felaktig och innehåller för många tecken");
  12. }
  13. String[] lines = replaceinput.split("\n", -1);
  14. int linescount = lines.length;
  15. if (linescount != 9) {
  16. throw new IllegalArgumentException("Din string är felaktig och innehåller för många rader");
  17. }
  18.  
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement