-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.java
More file actions
35 lines (32 loc) · 821 Bytes
/
sample.java
File metadata and controls
35 lines (32 loc) · 821 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
interface Resizable {
void resizeWidth(int width);
void resizeHeight(int height);
}
class Rectangle implements Resizable{
private int width;
private int height;
public Rectangle(int width, int height){
this.width=width;
this.height=height;
}
@Override
public void resizeWidth(int width){
this.width=width;
}
@Override
public void resizeHeight(int height){
this.height=height;
}
public void printsize(){
System.err.println("width:"+width+",Height"+height);
}
}
public class sample{
public static void main(String[] args) {
Rectangle rectangle= new Rectangle(100,150);
rectangle.printsize();
rectangle.resizeWidth(100);
rectangle.resizeHeight(150);
rectangle.printsize();
}
}