-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOblong.java
More file actions
51 lines (43 loc) · 944 Bytes
/
Oblong.java
File metadata and controls
51 lines (43 loc) · 944 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
42
43
44
45
46
47
48
49
50
51
public class Oblong
{
// the attributes
private double length;
private double height;
// the methods
// the constructor
public Oblong(double lengthIn, double heightIn)
{
length = lengthIn;
height = heightIn;
}
// this method allows us to read the length attribute
public double getLength()
{
return length;
}
// this method allows us to read the height attribute
public double getHeight()
{
return height;
}
// this method allows us to write to the length attribute
public void setLength(double lengthIn)
{
length = lengthIn;
}
// this method allows us to write to the height attribute
public void setHeight(double heightIn)
{
height = heightIn;
}
// this method returns the area of the rectangle
public double calculateArea()
{
return length * height;
}
// this method returns the perimeter of the rectangle
public double calculatePerimeter()
{
return 2 * (length + height);
}
}