-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathShape.java
More file actions
42 lines (34 loc) · 1.05 KB
/
Shape.java
File metadata and controls
42 lines (34 loc) · 1.05 KB
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
package src.ex4;
public abstract class Shape {
protected String color;
protected boolean filled;
public Shape() {
color = "red";
filled =true;
}
public Shape(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isFilled(){
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
abstract public double getArea();
abstract public double getPerimeter();
public String toString() {
// StringBuilder sb = new StringBuilder();
// Formatter formatter = new java.util.Formatter(sb);
// formatter.format("A Shape with color of %s and %s", color, (filled ? "filled" : "not filled"));
// return sb.toString();
return String.format("A Shape with color of %s and %s", color, (filled ? "filled" : "not filled"));
}
}