Not enough feedback, that will change. 

Not enough time to review for the midterm. 

Midterm Exam is pushed to Thu July 17. 

Head-First Java is the review guide for the exam. 

We looked at Intro Chapters 1-2 in Lecture Nine. 

I hope to summarize three more chapters for tomorrow. 

Go to Lecture Ten find and download the classes linked there.

Open them up in DrJava and then compile and run them. 

- Kexin, Mary Anne, Max, Neelan, Erik, Justin, Daniel
- Blake, Scott, Stacy, Justin, Artur, Yinan, Amber, Zhichao
- (Yi), Ruifeng, Adam, Adam, JSON
- Kyle, Dylan, Lindsay, Austin, Alex, Jordan, Hang, Yunsheng, Maxine

That was the attendance at 11:57am. 

Yesterday we talked about interfaces and abstract classes. 

Let's talk about abstract classes a bit more. 

class Point /* extends java.lang.Object */ {
  int x, y; 
  Point(int x, int y) {
    this.x = x; 
    this.y = y;
  }
  double distanceTo(Point that) {
    int dx = this.x - that.x; 
    int dy = this.y - that.y;
    return Math.sqrt( dx * dx + dy * dy );
  }
  public String toString() {
    return "(" + this.x + ", " + this.y + ")";  
  }
  public static void main(String[] args) {
    Point a = new Point(2, 3); 
    System.out.println( a ); 
    System.out.println( new Point(-1, 4) ); 
  }
}

I tested and developed and validated Point. 

Let's define the basic structure of our graphics program:

import javax.swing.JFrame; 

class One extends JFrame {
  One() {
    this.getContentPane().add( new Screen() ); 
    this.setVisible( true ); 
    this.setSize( 400, 500 ); 
  }
  public static void main(String[] args) {
    JFrame a = new One(); // polymorphism 
  }
}

We also defined a JComponent:

import javax.swing.JComponent; 
import java.awt.Graphics; 
import java.awt.Color; 

class Screen extends JComponent {
  public void paintComponent(Graphics g) {
    System.out.println("I am printing, or painting..."); 
    g.setColor(Color.YELLOW); 
    g.fillOval(50, 50, 100, 100); 
    g.setColor(Color.BLACK); 
    g.drawOval(50, 50, 100, 100); 
    
  }
}

We run this and it works. 

Next we modify Screen a little:

import javax.swing.JComponent; 
import java.awt.Graphics; 
import java.awt.Color; 

class Screen extends JComponent {
  int count = 0;
  public void paintComponent(Graphics g) {
    this.count = this.count + 1; 
    System.out.println("I am painting... " + this.count); 
    g.setColor(Color.YELLOW); 
    g.fillOval(50, 50, 100, 100); 
    g.setColor(Color.BLACK); 
    g.drawOval(50, 50, 100, 100); 
    
  }
}

This way we can investigate when and how many times paintComponent(...) is called. 

(to be continued in lab)