Object oriented programming is the beginning of the notion of framework. 

Frameworks exhibit what's called "inversion of control". 

They are not libraries of functions. 

https://en.wikipedia.org/wiki/Inversion_of_control

So remember: 

  (a) the class extension mechanism 

  (b) polymorphism 

  (c) inheritance

  (d) dynamic method lookup (overriding of methods)

  (e) constructor chaining 

We also know:

  (a) classes

  (b) abstract classes

  (c) interfaces

In the morning we basically agreed on this:

public abstract class Shape {
  public abstract double area(); 
}

public class Circle extends Shape {
  public double area() { return Math.random(); } 
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Shape a = new Circle()
> a.area()
0.9545833580277745


--

interface Shape {
  public double area(); 
}

public class Circle implements Shape {
  public double area() { return Math.random(); } 
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Shape a = new Circle()
> a.area()
0.674240929874026


https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html

https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#sort-java.util.List-java.util.Comparator-

https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#sort-java.util.List-

import java.util.ArrayList; 
import java.util.Collections;

public class Student implements Comparable<Student> {
  public int compareTo(Student other) {
    // descending by age
    if (this.age > other.age) return -1; 
    else if (this.age < other.age) return 1; 
    else return this.name.compareTo(other.name); 
  }
  private String name; 
  private int age;
  public Student(String n, int a) {
    this.name = n; 
    this.age = a; 
  }
  public String toString() {
    return this.name + ":" + this.age;  
  }
  public static void main(String[] args) {
    ArrayList<Student> a = new ArrayList<Student>();  
    a.add(new Student("Leslie", 8)); 
    a.add(new Student("Les"   , 8)); 
    a.add(new Student("Laura" , 6)); 
    a.add(new Student("German", 5)); 
    a.add(new Student("Larry" , 6)); 
    a.add(new Student("Louise", 8)); 
    a.add(new Student("Louis" , 3)); 
    System.out.println( a ); 
    // let's sort descending by age 
    Collections.sort( a ); 
    System.out.println( a ); 
    
  }
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Student
[Leslie:8, Les:8, Laura:6, German:5, Larry:6, Louise:8, Louis:3]
[Les:8, Leslie:8, Louise:8, Larry:6, Laura:6, German:5, Louis:3]


Young Hwan Namit Michael Chase Dustin Daohui Sai Nariman Ben Mary 
Chun Jiongran Sunghyun Grant Emma Yuying Zack Qi Stephen K Murun T
Peter F Peter W JeVante Q Nick F Adrian G

import java.util.ArrayList; 
import java.util.Collections;

public class Student implements Comparable<Student> {
  public int compareTo(Student other) {
    // descending by age
    if (this.age > other.age) return -1; 
    else if (this.age < other.age) return 1; 
    else return this.name.compareTo(other.name); 
  }
  private String name; 
  private int age;
  private int points; 
  public int points() {
    return this.points;  
  }
  public Student(String n, int a, int points) {
    this.name = n; 
    this.age = a; 
    this.points = points; 
  }
  public String toString() {
    return this.name + ":" + this.age + "/" + this.points;  
  }
  public static void main(String[] args) {
    ArrayList<Student> a = new ArrayList<Student>();  
    a.add(new Student("Leslie", 8, 19)); 
    a.add(new Student("Les"   , 8, 23)); 
    a.add(new Student("Laura" , 6, 21)); 
    a.add(new Student("German", 5, 18)); 
    a.add(new Student("Larry" , 6, 25)); 
    a.add(new Student("Louise", 8, 20)); 
    a.add(new Student("Louis" , 3, 17)); 
    System.out.println( a ); 
    // let's sort descending by age 
    Collections.sort( a ); 
    System.out.println( a ); 
    
    // sort again as follows: 
    //   first all the numbers 21 and less descending 
    //   then you want all the numbers 22 and above ascending 
    Collections.sort(a , new Weird()); 

    System.out.println( a ); 
  }
}

import java.util.Comparator; 

public class Weird implements Comparator<Student> {
  public int compare(Student a, Student b) {
    if (a.points() > 21 && b.points() > 21) return a.points() - b.points(); 
    else if (a.points() <= 21 && b.points() <= 21) return b.points() - a.points();
    else if (a.points() > 21) return 1; 
    else return -1;    
  }
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Student
[Leslie:8/19, Les:8/23, Laura:6/21, German:5/18, Larry:6/25, Louise:8/20, Louis:3/17]
[Les:8/23, Leslie:8/19, Louise:8/20, Larry:6/25, Laura:6/21, German:5/18, Louis:3/17]
[Laura:6/21, Louise:8/20, Leslie:8/19, German:5/18, Louis:3/17, Les:8/23, Larry:6/25]