Define Java Class 2
Before you solve this problem, solve the one before it as we will just extend it here, in this problem you are asked to write a Java class named Robot with the following specs.
- The name of the class is Robot
- The class has only two private fields
- int xPosition
- int yPosition
- The class has two constructors
- Robot(int xInitial, int yInitial) that initializes xPosition and yPosition to these values
- Robot() that initializes xPosition and yPosition to 0, 0
- The class has two public accessor/getter methods
- int getXPosition which returns the xPosition of the robot
- int getYPosition which returns the yPosition of the robot
- The class has four public mutator methods
- void moveRight(int dx) moves the robot by dx in the x direction
- void moveLeft(int dx) moves the robot by -dx in the x direction
- void moveUp(int dy) moves the robot by +dy in the y direction
- void moveDown(int dy) moves the robot by -dy in the y direction
The main method is hidden from you, you only have to write the code for the Robot class in Robot.java file below.
The code checker will check your implementation against the specs provided above.
There will be no input and output for this problem.
Test your solution here
when it passes, copy it and submit it here so your coach can grade it.