-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLint454.java
More file actions
30 lines (27 loc) · 836 Bytes
/
Lint454.java
File metadata and controls
30 lines (27 loc) · 836 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
package chen.practice;
/*Implement a Rectangle class which include the following attributes and methods:
* 1. Two public attributes width and height.
* 2. A constructor which expects two parameters width and height of type int.
* 3. A method getArea which would calculate the size of the rectangle and return.
*/
public class Lint454 {
/*
* Define two public attributes width and height of type int.
*/
public int width;
public int height;
/*
* Define a constructor which expects two parameters width and height here.
*/
public Lint454(int width, int height) {
this.height = height;
this.width = width;
}
/*
* Define a public method `getArea` which can calculate the area of the
* rectangle and return.
*/
public int getArea() {
return width*height;
}
}