Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. private static String[][] board2 = {new String[]{"A1", "A2", "A3", "A4", "A5"},
  2. new String[]{"B1", "B2", "B3", "B4", "B5"}};
  3.  
  4. public static void main(String args[]) {
  5.  
  6. Scanner stdin = new Scanner(System.in);
  7.  
  8. boolean textIsGood = false;
  9. do {
  10. System.out.println("Enter in A1-E5");
  11.  
  12. String text = stdin.nextLine();
  13.  
  14. char[] chars = text.toCharArray();
  15. System.out.println("Length " +chars.length);
  16. if (chars.length == 2) {
  17. char letter = chars[0];
  18. char number = chars[1];
  19.  
  20. System.out.println("Letter entered: " +letter);
  21. System.out.println("Number entered: " +number);
  22. if (Character.isDigit(number)) {
  23. int actualNumber = Integer.parseInt(number +"");
  24. System.out.println("Is a digit!");
  25. if (actualNumber >= 1) {
  26. System.out.println("Made it here 1");
  27. if (actualNumber < 6) {
  28. System.out.println("Made it here 2");
  29. if (Character.isAlphabetic(letter)) {
  30. char letterSimplified = Character.toLowerCase(letter);
  31. int characterValue = (int) letterSimplified;
  32. if (characterValue >= 97 && characterValue <= 101) {
  33. textIsGood = true;
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }
  40.  
  41. } while (!textIsGood);
  42.  
  43.  
  44.  
  45. ArrayList<Integer> shipPositions = new ArrayList<>();
  46.  
  47. while (shipPositions.size() != 3) {
  48. int number = randInt(0, 10);
  49. if (!shipPositions.contains(number)) {
  50. shipPositions.add(number);
  51. }
  52. }
  53.  
  54.  
  55. HashMap<Integer, Boolean> shipHasBeenHit = new HashMap<>();
  56. for (Integer i : shipPositions) {
  57. shipHasBeenHit.put(i, false);
  58. }
  59.  
  60. shipHasBeenHit.put(0, true);
  61.  
  62. int counter = 0;
  63. for (Map.Entry<Integer, Boolean> entry : shipHasBeenHit.entrySet()) {
  64. Boolean value = entry.getValue();
  65.  
  66. if (value) {
  67. counter++;
  68. }
  69. // ...
  70. }
  71.  
  72. System.out.println("counter: " +counter);
  73. // if (counter == 7) {
  74. //
  75. // }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement