-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotCom.java
More file actions
44 lines (37 loc) · 1.32 KB
/
Copy pathDotCom.java
File metadata and controls
44 lines (37 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// DotCom Changes
/*
** 3 boats generation and comparison for 3 boats through loop
** Visual look to the battlefield in the form of Cells
** Non identical but overlapped and intersected
*/
import java.util.*;
import java.util.Scanner;
public class DotCom extends DotComMaster{
public static void main(String[] args) {
int numberOfGuesses = 0;
int numberOfBoats;
Scanner scn = new Scanner(System.in);
DotCom dotCom = new DotCom();
System.out.println("[INFO] Game initialization in progress..");
System.out.print("[PROMPT] Enter number of boats: ");
numberOfBoats = scn.nextInt();
dotCom.initDotCom(numberOfBoats);
System.out.println("[INFO] Game initialized.\n\n");
System.out.println(dotCom);
int boatsKilled = 0;
String[] boatsStatusArr;
while(boatsKilled < numberOfBoats){
System.out.print("[PROMPT] Enter your guess ");
boatsStatusArr = dotCom.checkYourself(new Scanner(System.in).nextLine());
numberOfGuesses++;
System.out.println(dotCom);
System.out.println();
for(int z = 0; z < boatsStatusArr.length; z++)
if(boatsStatusArr[z].equals("kill"))
boatsKilled++;
} // end while
System.out.println("[INFO] Game Over.");
System.out.println("[INFO] You took " + numberOfGuesses + " guesses.");
}
}
// Adding a new comment