what is this one line that reads " copy another rectangle" ?? what does it actually mean? I haven't written any method for copying of parameters but yet it passed. How to create a copy function?
hidden #10462592
Level 8
satisfied all conditions but...
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Phan-Chuong Vo
18 August 2019, 23:21
you can try the following code below
public class Rectangle {
//write your code here
int top, left, width, height;
public void initialize (int top, int left) {
this.top = top;
this.left = left;
width = 0;
height = 0;
}
public void initialize (int top, int left, int width) {
this.top = top;
this.left = left;
this.width = width;
height = this.width;
}
public void initialize (int top, int left, int width, int height) {
this.top = top;
this.left = left;
this.width = width;
this.height = height;
}
public void initialize (Rectangle copy) {
this.top = copy.top;
this.left = copy.left;
this.width = copy.width;
this.height = copy.height;
}
public static void main(String[] args) {
}
}
+7
hidden #10462592
24 August 2019, 17:17
Nice!! I had no idea about this syntax. I will try to use it somewhere. thanks!! :) .
0