Table of Scores

Unit Score Grading
Unit 1 0.9/1 Link
Unit 2 0.95/1 Link
Unit 3 0.9/1 Link.html)
Unit 4 0.8/1 Link
Unit 5 0.9/1 Link
TOTAL SCORE 4.45/5 N/A

Unit 1: Primitives

See Jupyter Notebook here

Takeaways:

  • Java provides wrapper classes for all primitive data types like char, int, double, boolean where you can call in static methods that return values
  • Primitive wrapper objects or string objects are immutable so the methods can't change
  • Boolean, char, int, float, double are all primitive data types
  • String, Array, etc. are non-primitive data types
  • String class are unable to be changed
  • Learned to declare a variable that can be accessible and/or changed
  • Learned how to store data as variables
  • (=) is used to initialize variables or change its associated value
  • Operators are + - * / %
  • Compound operators are +=, -=, *=, /=, %=
  • Increment/decrement ++ or --
public class Integer103
{
    public static void main(String[] args)
    {
        System.out.println(Integer.MAX_VALUE);
        System.out.println(Integer.MIN_VALUE);

        int low = Integer.MAX_VALUE;
        int high = Integer.MIN_VALUE;
    }
}
Integer103.main(null);
// creating a class, wrapper classes for int
2147483647
-2147483648

Unit 2: Objects

See Jupyter Notebook here

Takeaways:

  • Learned the difference between classes vs. objects
  • Classes are blueprints for creating objects
  • Objects are instances within a class
  • Methods: certain set of code that runs a specific task
  • Class attributes are inherited by objects
  • Learned about myPainter in Code.org
  • Non static methods are dot operators
  • Overloaded methods give multiple methods the same name with different signatures
  • Void methods don't return values
  • Non void methods return a value of the same type defined in the method signature
  • Strings are created with String class constructor
  • Wrapper class: integer and double class are part of the java.lang package
  • Comparing numbers and objects using .equals()
  • static methods are a part of a class instead of an instance of a class which is why it's in a bracket in the class
  • class methods were just like in Code.org lessons
  • math classes are static that directly invoke methods
public class ComparingObjects  
{  
public static void main(String[] args)   
{  
//creating constructor of the Double class   
Double x = new Double(100.50);  
//creating constructor of the Long class   
Long y = new Long(12345);  
//invoking the equals() method   
System.out.println("Objects are not equal, hence it's " + x.equals(y));  
}  
}  
ComparingObjects.main(null);
// comparing objects using .equals()
Objects are not equal, hence it's false
public class JavaMathExample1    
{    
    public static void main(String[] args)     
    {    
        double x = 28;    
        double y = 4;    
          
        // return the maximum of two numbers  
        System.out.println("Maximum number of x and y is: " +Math.max(x, y));   
          
        // return the square root of y   
        System.out.println("Square root of y is: " + Math.sqrt(y));   
          
        //returns 28 power of 4 i.e. 28*28*28*28    
        System.out.println("Power of x and y is: " + Math.pow(x, y));      
  
        // return the logarithm of given value       
        System.out.println("Logarithm of x is: " + Math.log(x));   
        System.out.println("Logarithm of y is: " + Math.log(y));  
          
        // return the logarithm of given value when base is 10      
        System.out.println("log10 of x is: " + Math.log10(x));   
        System.out.println("log10 of y is: " + Math.log10(y));    
          
        // return the log of x + 1  
        System.out.println("log1p of x is: " +Math.log1p(x));    
  
        // return a power of 2    
        System.out.println("exp of a is: " +Math.exp(x));    
          
        // return (a power of 2)-1  
        System.out.println("expm1 of a is: " +Math.expm1(x));  
    }    
}  
JavaMathExample1.main(null);
Maximum number of x and y is: 28.0
Square root of y is: 2.0
Power of x and y is: 614656.0
Logarithm of x is: 3.332204510175204
Logarithm of y is: 1.3862943611198906
log10 of x is: 1.4471580313422192
log10 of y is: 0.6020599913279624
log1p of x is: 3.367295829986474
exp of a is: 1.446257064291475E12
expm1 of a is: 1.446257064290475E12

Unit 3: Boolean

See Jupyter Notebook #1 here

See Jupyter Notebook #2 here

Takeaways:

  • Whether boolean expression is true or false dictates whether the code will run
  • If-else statements sets up alternate code if the first expression turns false
  • Else-if statements allow for more conditions to be defined
  • De Morgan's law: logical operators && (and) ll(or) and !(not)
  • Comparing objects through ==
  • Compound boolean expression check multiple values in a single statement with && - like DeMorgan's Law
public class Test1
{
   public static void main(String[] args)
   {
     boolean cleanedRoom = true;
     boolean didHomework = false;
     if (cleanedRoom && didHomework)
     {
         System.out.println("You can go out");
     }
     else
     {
         System.out.println("No, you can't go out");
     }
   }
}
Test1.main(null);
No, you can't go out

Unit 4: Iteration

See Jupyter Notebook here

Takeaways:

  • While/for loops: repeats lines of code until a specific condition comes out false; can iterate over multiple elements
  • For loops are most tested
  • Strings: array chairs
  • Nested iteration: loop within a loop like when we did the monkeys and the rhymes
import java.util.ArrayList;

/*
 * Creator: Nighthawk Coding Society
 * Mini Lab Name: Hello Series,featuring Monkey Jumpers
 */

/**
 * Class for Monkey: a 2D array of Monkey
 * As well as method to print the Poem
 */
class Monkey {
    //The area between class definition and the 1st method is where we keep data for object in Java
    private static ArrayList<String[]> monkeyList = new ArrayList<String[]>();    //2D Array: AP CSA Unit 8: 2D array of strings
    private String[] monkeyASCII;

    /**
     * Constructor initializes a 2D array of Monkey
     */
    public Monkey(String[] monkeyASCII) {
        this.monkeyASCII = monkeyASCII;
        monkeyList.add(monkeyASCII);
    }

    /**
     * Loop and print monkey in array
     * ... repeat until you reach zero  ...
     */
    public static void printPoem() {
        //begin the poem
        System.out.println();
        System.out.println("Monkey Jumpers Poem in Java with Objects!!!");

        // monkey (non-primitive) defined in constructor knows its length
        int monkeyCount = monkeyList.size();
        for (int i = 1; i <= monkeyCount; i++)  //loops through 2D array length forwards
        {

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

            //how many separate parts are there in a monkey monkey?
            for (int row = 0; row < i; 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 < monkeyList.get(row).length; col++) {

                    // prints specific part of the monkey from the column
                    System.out.print(monkeyList.get(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("Too many 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)  {
        Monkey monkey0 = new Monkey(new String[]{
            "ʕง ͠° ͟ل͜ ͡°)ʔ ",      //[0][0] eyes
            "  \\_⏄_/  ",      //[0][1] chin
            "  --0--   ",       //[0][2] body
            "  ⎛   ⎞   "        //[0][3] legs
        });
        Monkey monkey1 = new Monkey(new String[]{
            " ʕ༼ ◕_◕ ༽ʔ",       //[1][0]
            "  \\_⎏_/  ",
            "  ++1++  ",
            "   ⌋ ⌊   "
        });
        Monkey monkey2 = new Monkey(new String[]{
            " ʕ(▀ ⍡ ▀)ʔ",       //[2][0]
            "  \\_⎐_/ ",
            "  <-2->  ",
            "  〈  〉 "
        });
        Monkey monkey3 = new Monkey(new String[]{
            "ʕ ͡° ͜ʖ ° ͡ʔ",        //[3][0]
            "  \\_⍾_/  ",
            "  ==3==  ",
            "  _/ \\_  "
        });
        Monkey monkey4 = new Monkey(new String[]{
            "  (◕‿◕✿) ",          //[4][0]
            "  \\_⍾_/ ",          //[4][1]
            "  ==4==  ",          //[4][2]
            "  _/ \\_ "           //[4][3]
        });

        
        Monkey.printPoem();   //a new monkey list and output in one step
    }

}

Monkey.main(null);
Monkey Jumpers Poem in Java with Objects!!!
1 little monkey jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    

2 little monkey jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    

 ʕ༼ ◕_◕ ༽ʔ 
  \_⎏_/   
  ++1++   
   ⌋ ⌊    

3 little monkey jumping on the bed...
ʕง ͠° ͟ل͜ ͡°)ʔ  
  \_⏄_/   
  --0--    
  ⎛   ⎞    

 ʕ༼ ◕_◕ ༽ʔ 
  \_⎏_/   
  ++1++   
   ⌋ ⌊    

 ʕ(▀ ⍡ ▀)ʔ 
  \_⎐_/  
  <-2->   
  〈  〉  

Too many monkeys jumping on the bed
0000000000000000000000000000000000
             THE END              

Unit 5: Writing Classes

See Jupyter Notebook here

Takeaways:

  • Classes are blueprints to create objects and define attributes
  • Instances: attributes, constructors, methods, objects
  • Public classes: no restricted access - constructors
  • Private classes: restricted access - instance variables
  • Accessor method (getter): allows other objects to obtain values of instance variables or static variables
  • Non void methods return a single value
  • toString() method is a overridden method that provides description of a specific object
  • Mutator Method (setter): void method that changes value of instance variables/static variable

Unit 6: Arrays

See Jupyter Notebook #1 here

See Jupyter Notebook #2 here

Takeaways:

  • Arrays: one type of data storage
  • Reference types
  • Need import java.util Arrays
  • Initialize arrays using constructors
  • Access elements through arrayName[index]

Reflection

Coming into AP CSA with absolutely no background did make the beginning of the year a little difficult. I remember feeling confused and unsure about a lot of concepts my classmates already knew. However, I soon started finding my rhythm. I began feeling more comfortable asking for help to Mr. M and my peers. I felt like the lessons were important for me to learn and apply the material. I learned the importance of practical application and creating tangible projects. My favorite activity of the year was defining the N@TM project because it was cool to see the intersection of code and Physics.