forked from JustinSDK/JavaSE6Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
30 lines (25 loc) · 814 Bytes
/
Rectangle.java
File metadata and controls
30 lines (25 loc) · 814 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
public class Rectangle {
// 受保護的member
protected int x;
protected int y;
protected int width;
protected int height;
public Rectangle() {
}
public Rectangle(int x, int y,
int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public void setX(int x) { this.x = x; }
public void setY(int y) { this.y = y; }
public void setWidth(int width) { this.width = width; }
public void setHeight(int height) { this.height = height; }
public int getX() { return x; }
public int getY() { return y; }
public int getWidth() { return width; }
public int getHeight() { return height; }
public int getArea() { return width*height; }
}