forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
61 lines (52 loc) · 1.01 KB
/
Rectangle.java
File metadata and controls
61 lines (52 loc) · 1.01 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
public class Rectangle
{
private int height;
private int width;
public Rectangle()
{
this.height = 1;
this.width = 1;
}
public Rectangle (int height, int width)
{
this.height = height;
this.width = width;
}
public Rectangle (Rectangle rectangle)
{
this.height = rectangle.height;
this.width = rectangle.width;
}
public int getHeight()
{
return height;
}
public int getWidth()
{
return width;
}
public int getArea()
{
return height*width;
}
public String toString()
{
return "Height: " + this.height + ", Width: " + this.width + ", Area: " + getArea();
}
public void doubleSize()
{
this.height *= 2;
this.width *= 2;
}
public String isSquare()
{
if(height == width)
{
return " is a SQUARE ◙";
}
else
{
return " is a RECTANGLE ◘";
}
}
}