-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
41 lines (32 loc) · 786 Bytes
/
Square.java
File metadata and controls
41 lines (32 loc) · 786 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
package prg.es4;
import prg.es2.Drawable;
public class Square extends Rectangle{
//COSTRUTTORI:
public Square(){}
public Square(int side){
this.setSide(side);
}
//METODI:
public Square setSide(int side){
super.setWidth(side);
super.setLength(side);
return this;
}
@Override
public Square setWidth(int side){
this.setSide(side);
return this;
}
@Override
public Square setLength(int side){
this.setSide(side);
return this;
}
public String toString(){
return "Square, " + "Colour: " + this.getColour() + ", Fill: " + this.getFill() +", Side: " + this.getWidth() + ", Perimeter: " + this.perimeter() + ", Area: " + this.area();
}
@Override
public void draw(){
System.out.println(this.toString());
}
}