0..
i think you took few extra variables..
to represent a rectangle u need atmost 4 variables. which you can do in two easy ways..
0.0..
int TopLeftx,TopLefty;// to represent top left coordinates of the rectangle.
int Width,Height;//to represent the width and height of the rectangle respectively 0.1..
int TopLeftx,TopLefty;//same as previous
int BottomRightx,BottomRighty;// to represent bottom right x and y coordinates. well these are not the only methods.. A more structured way would be to use two Point objects to represent the top left and bottom right coordinates of the rectangle.You can easily calculate the width and height of the rectangle from those.
->
Point TopLeft,BottomRight;
1..
ur assing.. says ->
"Add at the class Rectangle a method move(Point p) which
moves the rectangle
you did ->
public Point move(int ax, int ay)
{
x = ax;
y = ay;
Point v = new Point(x, y);
return v;
} function header should be like this ->
public void move ( Point p)
2..
then ur asng.. says ->method translate(int x, int y) which translates the rectangle to the right along the 0x coordinate axis and downward along the 0y coordinate axis
u wrote ->
nothing... :!:
translate(...) does nothing but it simply decreases the value of top left x coordinate value by the value passed to the function and increases the value of top left y coordinate coordinate by the corresponding value passed to the function (in case of screen coordinates , since here the (0,0) coordinate is the top right cornor or your screen).. keeping the width and height of the rectangle same..
{ they have used 0x and 0y as variable names in the problem discription.. you better use those names.. although thats not mandatory in general}
Try it urself..Its easy.
well.
Thats all for now.