forked from angiejones/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
41 lines (31 loc) · 826 Bytes
/
Copy pathRectangle.java
File metadata and controls
41 lines (31 loc) · 826 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 chapter6;
public class Rectangle {
private double length;
private double width;
public Rectangle(){
length = 0;
width = 0;
}
public Rectangle(double length, double width){
this.length = length; //can be set this way
setWidth(width); //or can be set this way. these are only different here to demo alternative options
}
public double getLength(){
return length;
}
public void setLength(double length){
this.length = length;
}
public double getWidth(){
return width;
}
public void setWidth(double width){
this.width = width;
}
public double calculatePerimeter(){
return (2 * length) + (2 * width);
}
public double calculateArea(){
return length * width;
}
}