-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShape.java
52 lines (41 loc) · 992 Bytes
/
Shape.java
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
46
47
48
49
50
51
52
package prg.es4;
import prg.es2.Drawable;
import prg.es2.Scalable;
public abstract class Shape implements Drawable, Scalable{
private String colour;
private boolean fill;
private static String[] setOfColours = {"Red", "Orange", "Yellow", "Blue", "Black"};
//METODI:
public Shape fillOn(){
fill = true;
return this;
}
public Shape fillOff(){
fill = false;
return this;
}
public Shape setColour(String colour){
boolean check = false;
for(String tmp : setOfColours){
if(tmp.equals(colour)){
this.colour = colour;
check = true;
}
}
if(check == false){
System.out.println("Colore non valido.");
}
return this;
}
public boolean getFill(){
return this.fill;
}
public String getColour(){
return this.colour;
}
public String toString(){
return ", Colour: " + this.getColour() + ", Fill: " + this.getFill();
}
public abstract double perimeter();
public abstract double area();
}