Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String[][] board2 = {new String[]{"A1", "A2", "A3", "A4", "A5"},
- new String[]{"B1", "B2", "B3", "B4", "B5"}};
- public static void main(String args[]) {
- Scanner stdin = new Scanner(System.in);
- boolean textIsGood = false;
- do {
- System.out.println("Enter in A1-E5");
- String text = stdin.nextLine();
- char[] chars = text.toCharArray();
- System.out.println("Length " +chars.length);
- if (chars.length == 2) {
- char letter = chars[0];
- char number = chars[1];
- System.out.println("Letter entered: " +letter);
- System.out.println("Number entered: " +number);
- if (Character.isDigit(number)) {
- int actualNumber = Integer.parseInt(number +"");
- System.out.println("Is a digit!");
- if (actualNumber >= 1) {
- System.out.println("Made it here 1");
- if (actualNumber < 6) {
- System.out.println("Made it here 2");
- if (Character.isAlphabetic(letter)) {
- char letterSimplified = Character.toLowerCase(letter);
- int characterValue = (int) letterSimplified;
- if (characterValue >= 97 && characterValue <= 101) {
- textIsGood = true;
- }
- }
- }
- }
- }
- }
- } while (!textIsGood);
- ArrayList<Integer> shipPositions = new ArrayList<>();
- while (shipPositions.size() != 3) {
- int number = randInt(0, 10);
- if (!shipPositions.contains(number)) {
- shipPositions.add(number);
- }
- }
- HashMap<Integer, Boolean> shipHasBeenHit = new HashMap<>();
- for (Integer i : shipPositions) {
- shipHasBeenHit.put(i, false);
- }
- shipHasBeenHit.put(0, true);
- int counter = 0;
- for (Map.Entry<Integer, Boolean> entry : shipHasBeenHit.entrySet()) {
- Boolean value = entry.getValue();
- if (value) {
- counter++;
- }
- // ...
- }
- System.out.println("counter: " +counter);
- // if (counter == 7) {
- //
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement