Changing the inheritance example from
March 17th: Picture.java is now an abstract class. Everything else
works as before.
import java.awt.*;
public abstract class Picture {
protected int x;
protected int y;
protected int w;
protected int h;
protected Color c;
public Picture (int x, int y, int w, int h, Color c) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.c = c;
}
// method draw will be overwritten in subclasses:
public abstract void draw(Graphics g);
public boolean isGreen() {
System.out.println("is Green called");
return c == Color.green;
}
}
This is an example from CSci 1211 course.