- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotCom.java
More file actions
Latest commit
executable file
·34 lines (29 loc) · 839 Bytes
/
Copy pathDotCom.java
File metadata and controls
executable file
·34 lines (29 loc) · 839 Bytes
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
importjava.util.ArrayList;
publicclassDotCom {
privateArrayList<String> locationCells;
publicvoidsetLocationCells(ArrayList<String> loc)
{
locationCells = loc;
}
publicStringcheckYourself(StringuserInput)
{
Stringresult = "miss";
intindex = locationCells.indexOf(userInput);
if (index >= 0) {
locationCells.remove(index);
if (locationCells.isEmpty()) {
result = "kill";
}
else
{
result = "hit";
}
}
returnresult;
}
//TODO: all the following code was added and should have been included in the book
privateStringname;
publicvoidsetName(Stringstring) {
name = string;
}
}