1 // GeometricObject.java: The abstract GeometricObject class
2 public class GeometricObject implements Comparable{
3 protected String color = "white";
4 protected boolean filled;
5 protected int a;
6
7 /**Default construct*/
8 protected GeometricObject() {
9 filled = false;
10 }
11
12 /**Construct a geometric object*/
13 protected GeometricObject(String color, int a,boolean filled) {
14 this.color = color;
15 this.a = a;
16 this.filled = filled;
17 }
18
19 public static Comparable max(Comparable c1,Comparable c2){
20 if(c1.compareTo(c2)>0)
21 return c1;
22 else return c2;
23 }
24 public int compareTo(Object o){
25 if(this.getArea() > ((GeometricObject)o).getArea())
26 return 1;
27 else if (this.getArea() == ((GeometricObject)o).getArea())
28 return 0;
29 else return -1;
30 }
31 /**Getter method for color*/
32 public String getColor() {
33 return color;
34 }
35
36 /**Setter method for color*/
37 public void setColor(String color) {
38 this.color = color;
39 }
40
41 /**Getter method for filled. Since filled is boolean,
42 so, the get method name is isFilled*/
43 public boolean isFilled() {
44 return filled;
45 }
46
47 /**Setter method for filled*/
48 public void setFilled(boolean filled) {
49 this.filled = filled;
50 }
51
52 /**Abstract method findArea*/
53 public int getArea(){
54 return a*a;
55 }
56
57 /**Abstract method getPerimeter*/
58 public double getPerimeter(){
59 return 1;
60 }
61 }