← Unit 3 · all exercises
Saved in this browser only

Moving a point

Write a Marker with an x and a y. move shifts it by the amounts given, and reset returns it to where it started. position returns text like "(3, 4)".

class Marker { Marker(int x, int y); void move(int dx, int dy); void reset(); String position(); }

Marker.java
Loading editor…
Results

Examples

  • new Marker(3, 4).position() → (3, 4)
  • Marker m = new Marker(0, 0); m.move(2, 3); m.position() → (2, 3)

There are also 3 hidden tests you can't see. Solve the problem, not the examples.