-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnts3.java
More file actions
49 lines (38 loc) · 1.23 KB
/
Copy pathAnts3.java
File metadata and controls
49 lines (38 loc) · 1.23 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
45
46
47
48
49
public class Ants3 {
/**
* Ants3.java
* Arrays are cool
*
*/
public static String[] distractionList =
{"", "suck his thumb", "tie his shoe", "climb a tree"};
public static void main(String[] args) {
//Hi there, this is a comment
for (int i = 1; i < distractionList.length; i++){
System.out.println(verse(i));
System.out.println(chorus());
}
} // end main
public static String chorus(){
String result = " \n";
result += "...and they all go marching \n";
result += "down \n";
result += "to the ground \n";
result += "to get out \n";
result += "of the rain \n";
result += "Boom boom boom boom boom boom boom boom \n";
result += " \n";
return result;
} // end chorus
public static String verse(int verseNum){
String result = "";
String distraction = distractionList[verseNum];
result += "The ants go marching " + verseNum;
result += " by " + verseNum + " hurrah, hurrah... \n";
result += "The ants go marching " + verseNum;
result += " by " + verseNum + " hurrah, hurrah... \n";
result += "The little one stops to " + distraction + " \n";
result += " \n";
return result;
} // end verse
} // end class def