-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
63 lines (50 loc) · 1.27 KB
/
Rectangle.java
File metadata and controls
63 lines (50 loc) · 1.27 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
52
53
54
55
56
57
58
59
60
61
62
63
import java.awt.Color;
public class Rectangle {
//instance variables
double xPosition;
double yPosition;
double width;
double height;
Color color;
//Constructor:
public Rectangle(double xPosition, double yPosition, double width, double height){
this.xPosition = xPosition;
this.yPosition = yPosition;
this.width = width;
this.height = height;
}
public double calculatePerimeter(){
return (this.width * 2.0) + (this.height * 2.0);
}
public double calculateArea(){
return (this.width * this.height);
}
public void setColor(Color color){
this.color = color;
}
public void setPos(double xPosition, double yPosition){
this.xPosition = xPosition;
this.yPosition = yPosition;
}
public void setHeight(double height){
this.height = height;
}
public void setWidth(double width){
this.width = width;
}
public Color getColor(){
return this.color;
}
public double getXPos(){
return this.xPosition;
}
public double getYPos(){
return this.yPosition;
}
public double getHeight(){
return this.height;
}
public double getWidth(){
return this.width;
}
}