Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void setBoard(String input) {
- String replaceinput = input.replaceAll("\\.", "0");
- int charcount = 0;
- for (int i = 0, len = replaceinput.length(); i < len; i++) {
- if (Character.isDigit(replaceinput.charAt(i))) {
- charcount++;
- }
- }
- if (charcount != 81) {
- throw new IllegalArgumentException("Din string är felaktig och innehåller för många tecken");
- }
- String[] lines = replaceinput.split("\n", -1);
- int linescount = lines.length;
- if (linescount != 9) {
- throw new IllegalArgumentException("Din string är felaktig och innehåller för många rader");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement