Today in class:

(a) I demonsrate the lab assignment

(b) we take a minute paper

(c) I introduce abstract classes, interfaces and applications of those

See the lab notes for the assignment. 

Minute paper: 

send an e-mail message to dgerman@indiana.edu

in it briefly describe what you have to do today in lab

if you are not sure ask questions about it

--

Are there any questions about the lab of yesterday? 

Let's look at some code: 

http://www.cs.indiana.edu/classes/c212-dgerman/spr2012/classNotes/review/testTen.html

The solution is:

http://silo.cs.indiana.edu:8346/04142012/001.html

Next let's ask a question for tomorrow: 

http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html

-bash-4.1$ ls -ld Jialin.java
-rw-r--r-- 1 dgerman faculty 438 Jul 16 13:01 Jialin.java
-bash-4.1$ cat Jialin.java
import java.util.*;

class One {
  public static void main(String[] args) {
    ArrayList<Object> shapes = new ArrayList<Object>();
    shapes.add(new Circle());
    shapes.add(new Rectangle());
    System.out.println( shapes );
  }
}

class Circle {
  Point location;
  int radius;
  public String toString() {
    return "I am a Circle!";
  }
}

class Point {

}

class Rectangle {
  Point location;
  int width, height;
}


-bash-4.1$ javac Jialin.java
-bash-4.1$ java One
[I am a Circle!, Rectangle@6774a144]
-bash-4.1$

How do we store Circles and Rectangles in one and a same array? 

How can we ask them *uniformly* what their areas are? 

(a) one is by brute force (with if and instanceof)

(b) is by better design (interfaces or abstract classes) 

Finally: 

How can we sort these geometrical objects descending by area? 

--