Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Rectangle;
- /**
- A tile for tiling the plane.
- */
- public class Tile extends Rectangle
- {
- /**
- Constructs a tile with given dimensions.
- @param x the x-coordinate of the top left corner
- @param y the y-coordinate of the top left corner
- @param width the width of the tile
- @param height the height of the tile
- */
- public Tile(int x, int y, int width, int height)
- {
- super(x, y, width, height);
- }
- @Override
- public void translate(int dx, int dy)
- {
- setLocation((int)(getX()+dx*getWidth()), (int)(getY()+dy*getHeight()));
- }
- // this method is used to check your work
- public static String check(int x, int y, int width, int height, int dx, int dy)
- {
- Tile t = new Tile(x, y, width, height);
- t.translate(dx, dy);
- return t.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement