2D Arrays
monkey poem
class MonkeyLoop {
String [][] monkeys;
public MonkeyLoop() {
monkeys = new String[][]{
//Monkey 0
{
"ʕง ͠° ͟ل͜ ͡°)ʔ ", //[0][0] eyes
" \\_⏄_/ ", //[0][1] chin
"---iris--- ", //[0][2] body
" ⎛ ⎞ " //[0][3] legs
},
//Monkey 1
{
" ʕ༼ ◕_◕ ༽ʔ ", //[1][0]
" \\_⎏_/ ",
" +++alice+++",
" ⌋ ⌊ "
},
//Monkey 2
{
" ʕ(▀ ⍡ ▀)ʔ ", //[2][0]
" \\_⎐_/ ",
" <-samaya-> ",
" 〈 〉 "
},
//Monkey 3
{
"ʕ ͡° ͜ʖ ° ͡ʔ ", //[3][0]
" \\_⍾_/ ",
"==sarayu== ",
" _/ \\_ "
},
//Monkey 4
{
" (◕‿◕✿) ", //[4][0]
" \\_⍾_/ ", //[4][1]
"==mr.mort== ", //[4][2]
" _/ \\_ " //[4][3]
},
};
}
public void printPoem() {
System.out.println();
System.out.println("Monkey Jumpers Poem in Java Loopy");
int monkeyCount = monkeys.length;
for (int i = monkeyCount; i >= 1; i--)
{
for (int col = 0; col < monkeys[col].length; col++) {
for (int row = 0; row < monkeyCount; row++) {
System.out.print(monkeys[row][col]); //print rows then columns instead of opposite
System.out.print("\t"); //insert tab in text to line up each monkey in row
}
System.out.println();
}
if (i > 1){
System.out.println(i + " little monkeys jumping on the bed...");
}
else{
System.out.println(i + " little monkey jumping on the bed...");
}
System.out.println("One fell down and bumped his head!");
System.out.println("Mama called the doctor and the doctor said:");
if (i == 1){ // if there is one monkey left, print the last line
System.out.println("Put those monkeys right to bed!");
}
else{
System.out.println("No more monkey's jumping on the bed!");
}
System.out.println();
monkeyCount -= 1;
}
System.out.println("0000000000000000000000000000000000");
System.out.println(" THE END ");
}
public static void main(String[] args) {
new MonkeyLoop().printPoem();
}
}
MonkeyLoop.main(null);