Iteration with 2D Array

Print monkeys horizontally and vertically

import java.util.*;  
class MonkeyLoop {
    //The area between class definition and the 1st method is where we keep data for object in Java
    String [][] monkeys;    //2D Array: AP CSA Unit 8: 2D array of strings
                            //2D array is like a grid [x][y]
                            // or like a spreadsheet [row][column]

    /**
     * Constructor initializes a 2D array of Monkeys
     */
    public MonkeyLoop() {
        //Storing Data in 2D arrays
        monkeys = new String[][]{   //2D array above is just a name, "new" makes a container ("object")
                //Monkey 0
                {
                        "Keely               ",      //[0][0]
                        "  /~\\               ",      //[0][1]
                        " C oo               ",       //[0][2]
                        " _( ^)              ",        //[0][3]
                        "/   ~\\              "        //[0][4]
                },
                //Monkey 1
                {
                        "ejm97               ",       //[1][0]
                        "w  c(..)o   (       ",
                        " \\__(-)    __)      ",
                        "     /\\   (         ",
                        "    /(_)___)        ",
                        "    w /|            ",       
                        "     | \\            ",
                        "    m  m            "
                },
                //Monkey 2
                {
                        "see no evil         ",       //[2][0]
                        "       .-\"-.        ",
                        "     _/_-.-_\\_      ",
                        "    / __} {__ \\     ",
                        "  / //  \"  \\\\ \\     ",
                        "  / / \\'---'/ \\ \\   ",       
                        "  \\ \\_/`\"\"\"`\\_/ /   ",
                        "   \\           /    "
                },
                //Monkey 3
                {
                        "have no fun         ",       //[3][0]
                        "   .-\"-.            ",
                        " _/.-.-.\\_          ",
                        "( ( o o ) )         ",
                        " |/  \"  \\|          ",
                        "  \\ .-. /           ",       
                        "  /`\"\"\"`\\           ",
                        " /       \\          "
                },
                //Monkey 4
                {
                        "hear no evil        ",       //[4][0]
                        "    ..-..           ",
                        "   /|'.'|\\          ",
                        "   \\)\\-/(/          ",
                        " __/ ' ' \\__        ",
                        "( (_/-._\\_) )       ",       
                        " '.Oo___oO.'        "
                },
                {
                        "talk no evil        ",       //[5][0]
                        "    _.-._           ",
                        "   (_'.'_)          ",
                        "    ,-.-.           ",
                        " __/'-'-'\\__        ",
                        "( (_/   \\_) )       ",       
                        " '.Oo___oO.'        "
                }
        };
    }

    public void printHorizontal() {
        int monkeyCount = monkeys.length;
        List<Integer> columnLengths = new ArrayList<Integer>();
        for (int i = 0; i < monkeyCount; i++) {
            columnLengths.add(monkeys[i].length);
        }
        int maxColLen = Collections.max(columnLengths);
        //how many separate parts are there in a monkey monkey?
        for (int row = 0; row < maxColLen; row++) {  //cycles through "cells" of 2d array

            /*cycles through columns to print
            each monkey part by part, will eventually print entire column*/
            for (int col = 0; col < monkeyCount; col++) {

                // prints specific part of the monkey from the column
                if (monkeys[col].length > row) {
                    System.out.print(monkeys[col][row]);
                } else {
                    System.out.print("                    ");
                }
            }
        System.out.println();
        }
    }
    public void printVertical() {
        int monkeyCount = monkeys.length;
        for (int i = monkeyCount; i >= 1; i--)  //loops through 2D array length backwards
        {
            //how many separate parts are there in a monkey monkey?
            for (int row = 0; row < monkeyCount; row++) {  //cycles through "cells" of 2d array

                /*cycles through columns to print
                each monkey part by part, will eventually print entire column*/
                for (int col = 0; col < monkeys[row].length; col++) {

                    // prints specific part of the monkey from the column
                    System.out.print(monkeys[row][col] + " ");

                    //this is new line between separate parts
                    System.out.println();
                }
            }
        }
    }
    /**
     * Loop and print monkeys in array
     * ... repeat until you reach zero  ...
     */
    /*
    public void printPoem() {
        //begin the poem
        System.out.println();
        System.out.println("Monkey Jumpers Poem in Java Loopy");

        // monkeys (non-primitive) defined in constructor knows its length
        int monkeyCount = monkeys.length;
        for (int i = monkeyCount; i >= 1; i--)  //loops through 2D array length backwards
        {

            //this print statement shows current count of Monkeys
            //  concatenation (+) of the loop variable and string to form a countdown message
            System.out.println(i + " little monkeys jumping on the bed...");

            //how many separate parts are there in a monkey monkey?
            for (int row = 0; row < monkeyCount; row++) {  //cycles through "cells" of 2d array

                /*cycles through columns to print
                each monkey part by part, will eventually print entire column*/ /*
                for (int col = 0; col < monkeys[row].length; col++) {

                    // prints specific part of the monkey from the column
                    System.out.print(monkeys[row][col] + " ");

                    //this is new line between separate parts
                    System.out.println();
                }

                //this new line gives separation between stanza of poem
                System.out.println();
            }

            //countdown for poem, decrementing monkeyCount variable by 1
            monkeyCount -= 1;
        }

        //out of all the loops, prints finishing messages
        System.out.println("No more monkeys jumping on the bed");
        System.out.println("0000000000000000000000000000000000");
        System.out.println("             THE END              ");
    }
    */
    /**
    * A Java Driver/Test method that is the entry point for execution
    */
    public static void main(String[] args)  {
        MonkeyLoop monke = new MonkeyLoop();
        monke.printHorizontal();
        monke.printVertical();
        // monke.printPoem();
    }

}
MonkeyLoop.main(null);
Keely               ejm97               see no evil         have no fun         hear no evil        talk no evil        
  /~\               w  c(..)o   (              .-"-.           .-"-.                ..-..               _.-._           
 C oo                \__(-)    __)           _/_-.-_\_       _/.-.-.\_             /|'.'|\             (_'.'_)          
 _( ^)                   /\   (             / __} {__ \     ( ( o o ) )            \)\-/(/              ,-.-.           
/   ~\                  /(_)___)          / //  "  \\ \      |/  "  \|           __/ ' ' \__         __/'-'-'\__        
                        w /|              / / \'---'/ \ \     \ .-. /           ( (_/-._\_) )       ( (_/   \_) )       
                         | \              \ \_/`"""`\_/ /     /`"""`\            '.Oo___oO.'         '.Oo___oO.'        
                        m  m               \           /     /       \                                                  
Keely                
  /~\                
 C oo                
 _( ^)               
/   ~\               
ejm97                
w  c(..)o   (        
 \__(-)    __)       
     /\   (          
    /(_)___)         
    w /|             
     | \             
    m  m             
see no evil          
       .-"-.         
     _/_-.-_\_       
    / __} {__ \      
  / //  "  \\ \      
  / / \'---'/ \ \    
  \ \_/`"""`\_/ /    
   \           /     
have no fun          
   .-"-.             
 _/.-.-.\_           
( ( o o ) )          
 |/  "  \|           
  \ .-. /            
  /`"""`\            
 /       \           
hear no evil         
    ..-..            
   /|'.'|\           
   \)\-/(/           
 __/ ' ' \__         
( (_/-._\_) )        
 '.Oo___oO.'         
talk no evil         
    _.-._            
   (_'.'_)           
    ,-.-.            
 __/'-'-'\__         
( (_/   \_) )        
 '.Oo___oO.'         
Keely                
  /~\                
 C oo                
 _( ^)               
/   ~\               
ejm97                
w  c(..)o   (        
 \__(-)    __)       
     /\   (          
    /(_)___)         
    w /|             
     | \             
    m  m             
see no evil          
       .-"-.         
     _/_-.-_\_       
    / __} {__ \      
  / //  "  \\ \      
  / / \'---'/ \ \    
  \ \_/`"""`\_/ /    
   \           /     
have no fun          
   .-"-.             
 _/.-.-.\_           
( ( o o ) )          
 |/  "  \|           
  \ .-. /            
  /`"""`\            
 /       \           
hear no evil         
    ..-..            
   /|'.'|\           
   \)\-/(/           
 __/ ' ' \__         
( (_/-._\_) )        
 '.Oo___oO.'         
talk no evil         
    _.-._            
   (_'.'_)           
    ,-.-.            
 __/'-'-'\__         
( (_/   \_) )        
 '.Oo___oO.'         
Keely                
  /~\                
 C oo                
 _( ^)               
/   ~\               
ejm97                
w  c(..)o   (        
 \__(-)    __)       
     /\   (          
    /(_)___)         
    w /|             
     | \             
    m  m             
see no evil          
       .-"-.         
     _/_-.-_\_       
    / __} {__ \      
  / //  "  \\ \      
  / / \'---'/ \ \    
  \ \_/`"""`\_/ /    
   \           /     
have no fun          
   .-"-.             
 _/.-.-.\_           
( ( o o ) )          
 |/  "  \|           
  \ .-. /            
  /`"""`\            
 /       \           
hear no evil         
    ..-..            
   /|'.'|\           
   \)\-/(/           
 __/ ' ' \__         
( (_/-._\_) )        
 '.Oo___oO.'         
talk no evil         
    _.-._            
   (_'.'_)           
    ,-.-.            
 __/'-'-'\__         
( (_/   \_) )        
 '.Oo___oO.'         
Keely                
  /~\                
 C oo                
 _( ^)               
/   ~\               
ejm97                
w  c(..)o   (        
 \__(-)    __)       
     /\   (          
    /(_)___)         
    w /|             
     | \             
    m  m             
see no evil          
       .-"-.         
     _/_-.-_\_       
    / __} {__ \      
  / //  "  \\ \      
  / / \'---'/ \ \    
  \ \_/`"""`\_/ /    
   \           /     
have no fun          
   .-"-.             
 _/.-.-.\_           
( ( o o ) )          
 |/  "  \|           
  \ .-. /            
  /`"""`\            
 /       \           
hear no evil         
    ..-..            
   /|'.'|\           
   \)\-/(/           
 __/ ' ' \__         
( (_/-._\_) )        
 '.Oo___oO.'         
talk no evil         
    _.-._            
   (_'.'_)           
    ,-.-.            
 __/'-'-'\__         
( (_/   \_) )        
 '.Oo___oO.'         
Keely                
  /~\                
 C oo                
 _( ^)               
/   ~\               
ejm97                
w  c(..)o   (        
 \__(-)    __)       
     /\   (          
    /(_)___)         
    w /|             
     | \             
    m  m             
see no evil          
       .-"-.         
     _/_-.-_\_       
    / __} {__ \      
  / //  "  \\ \      
  / / \'---'/ \ \    
  \ \_/`"""`\_/ /    
   \           /     
have no fun          
   .-"-.             
 _/.-.-.\_           
( ( o o ) )          
 |/  "  \|           
  \ .-. /            
  /`"""`\            
 /       \           
hear no evil         
    ..-..            
   /|'.'|\           
   \)\-/(/           
 __/ ' ' \__         
( (_/-._\_) )        
 '.Oo___oO.'         
talk no evil         
    _.-._            
   (_'.'_)           
    ,-.-.            
 __/'-'-'\__         
( (_/   \_) )        
 '.Oo___oO.'         
Keely                
  /~\                
 C oo                
 _( ^)               
/   ~\               
ejm97                
w  c(..)o   (        
 \__(-)    __)       
     /\   (          
    /(_)___)         
    w /|             
     | \             
    m  m             
see no evil          
       .-"-.         
     _/_-.-_\_       
    / __} {__ \      
  / //  "  \\ \      
  / / \'---'/ \ \    
  \ \_/`"""`\_/ /    
   \           /     
have no fun          
   .-"-.             
 _/.-.-.\_           
( ( o o ) )          
 |/  "  \|           
  \ .-. /            
  /`"""`\            
 /       \           
hear no evil         
    ..-..            
   /|'.'|\           
   \)\-/(/           
 __/ ' ' \__         
( (_/-._\_) )        
 '.Oo___oO.'         
talk no evil         
    _.-._            
   (_'.'_)           
    ,-.-.            
 __/'-'-'\__         
( (_/   \_) )        
 '.Oo___oO.'         

Questions

Is this program in more of an Imperative Programming Style or OOP style? Explain.

This program is in more of an OOP style because we are creating classes that has different functions within the MonkeyLoop class. We also run this program by initializing the object from the class MonkeyLoop and running its attributes.

Is each Monkey an object?

Each monkey is not an object because they are just a bunch of strings together.