-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetective.java
More file actions
35 lines (34 loc) · 1.37 KB
/
Copy pathDetective.java
File metadata and controls
35 lines (34 loc) · 1.37 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
import java.util.ArrayList;
class ToDos {
public static void main(String[] args) {
// Sherlock
ArrayList<String>
sherlocksToDos = new ArrayList<String>();
sherlocksToDos.add("visit the crime scene");
sherlocksToDos.add("play violin");
sherlocksToDos.add("interview suspects");
sherlocksToDos.add("solve the case");
sherlocksToDos.add("apprehend the criminal");
// Poirot
ArrayList<String> poirotsToDos = new ArrayList<String>();
poirotsToDos.add("visit the crime scene");
poirotsToDos.add("interview suspects");
poirotsToDos.add("let the little grey cells do their work");
public static void main(String[] args) {
poirotsToDos.add("reveal the truth of the crime");
// Print the size of each ArrayList below:
System.out.println("sherlocksToDo's size: "+ sherlocksToDos.size());
System.out.println("poirotsToDo's size: "+ poirotsToDos.size());
// Print the name of the detective with the larger to-do list:
if(poirotsToDos.size()<sherlocksToDos.size()){
System.out.println("Sherlock has more things to do");
}
else if(poirotsToDos.size()>sherlocksToDos.size()){
System.out.println("Poirot has more things to do");
} else if(poirotsToDos.size()==sherlocksToDos.size())
{ System.out.println("both detectives have same amount of things to do"); }
}
}
}
}
}