import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; // * abstract class: canNOT be instantiated (is NOT instantiable) // canNOT call the constructor with the "new" keyword // new Stroke(...) is an error // * new: goes to the memory, finds space big enough for object, // initializes all data members (instance variables), // and returns the address of the object public abstract class Stroke { protected static final Color DEFAULT_COLOR = Color.BLACK; // common data members // private: nobody but the current class has access // protected: keeps access to family protected int cx, cy; protected int size; // for now, radius for Circular, length for Square protected boolean filled; // data members are for actual drawing operations protected int ulx, uly; protected int width, height; // must be accessed through parent's public/protected/default methods private Color color; public Stroke(int x, int y, int s, boolean f) { this(x, y, s, f, DEFAULT_COLOR); } public Stroke(int x, int y, int s, boolean f, Color c) { cx = x; cy = y; size = s; filled = f; color = c; ulx = cx - size; uly = cy - size; width = size * 2; height = size * 2; } public Color getColor() { return color; } // when default behavior cannot be defined // (0) canNOT not have the method signature at least // (1) Fri Sep-13: some code that will never be executed // (2) Mon Sep-16: empty method body // (3) Mon Sep-16: make the method abstract (signature exists, no body) // * abstract method: body will be defined by descendants public abstract void draw(GraphicsContext gc) ; }