-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
34 lines (29 loc) · 868 Bytes
/
Rectangle.java
File metadata and controls
34 lines (29 loc) · 868 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
package jiuzhang.java.elementary;
// Rectangle Area
public class Rectangle {
/*
* Define two public attributes width and height of type int.
*/
// write your code here
public int width;
public int height; // *Note: class field do not need to be initialized outside constructor
/*
* Define a constructor which expects two parameters width and height here.
*/
// write your code here
public Rectangle(int width, int height) {
this.width = width;
this.height = height;
}
/*
* Define a public method `getArea` which can calculate the area of the
* rectangle and return.
*/
// write your code here
public int getArea() {
return this.width * this.height;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}