-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle1.java
More file actions
51 lines (37 loc) · 1.21 KB
/
Rectangle1.java
File metadata and controls
51 lines (37 loc) · 1.21 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
43
44
45
46
47
48
49
50
51
package lab6;
public class Rectangle1 extends GeometricObject {
private double width;
private double height;
public Rectangle1(){}
public Rectangle1(double width, double height) {
this.width = width;
this.height = height;
}
public Rectangle1(double width, double height, String color, boolean filled)
{
super(color,filled);
this.width = width;
this.height = height;
}
public double getPerimeter()
{
return 2*(this.height + this.width);
}
public double getDiameter()
{
return 2*(this.height + this.width);
}
public double getArea()
{
return this.height*this.width;
}
public void printRectangle()
{
System.out.println("Height is : " +this.height );
System.out.println("Width is :" +this.width);
System.out.println("Color is :" +super.getColor());
System.out.println("Perimeter is :" +this.getPerimeter());
System.out.println("Diameter is :" +this.getDiameter());
System.out.println("Area is :" +this.getArea());
}
}