-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyBoundedShape.java
More file actions
45 lines (34 loc) · 870 Bytes
/
MyBoundedShape.java
File metadata and controls
45 lines (34 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package A;
import java.awt.Color;
//abstract class that Represents close shapes like Oval and Rectangle.
public abstract class MyBoundedShape extends MyShape {
// whether this shape is filled
private boolean filled;
//constructor
public MyBoundedShape() {
super(0,0,0,0,Color.BLACK);
this.filled=false;
}
public MyBoundedShape(int x1, int x2, int y1, int y2, Color color,boolean filled) {
super(x1, x2, y1, y2, color);
this.filled=filled;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public int upperLeftCoordinateX(){
return Math.min(getX1(),getX2());
}
public int upperLeftCoordinateY(){
return Math.min(getY1(),getY2());
}
public int getWidth(){
return Math.abs(getX1()-getX2());
}
public int getHeight(){
return Math.abs(getY1()-getY2());
}
}