Question: java Create a class Robot. The robot moves around in a Cartesian coordinate system and can only move in only one direction (either X or

java java Create a class Robot. The robot moves around in a Cartesian

Create a class Robot. The robot moves around in a Cartesian coordinate system and can only move in only one direction (either X or y, but not both) at a time. A robot has a name, x position, y position, and total distance traveled. Implement the following constructor and methods: Robot(String name) constructor that sets the name attribute and initializes the remaining attributes to locate the robot at coordinate (0, 0) getName() getter, returns a String containing the robot name getxposition) getter, returns the current x position of the robot getter; returns the current y position of the robot getyPosition) moveX(int distance) adjusts the x position by distance and adds the distance to the total distance traveled moveY(int distance) adjusts the y position by distance and adds the distance to the total distance traveled distance Traveled.) returns the total distance traveled by the robot Develop an application named Prog3 that tests your Robot class. The test application will ask the user for the robot's name. It will then instantiate a Robot object using the name. The application will then use a loop to ask the user to enter direction (x or y) to move and the distance. The loop will terminate when the user enters a direction of a (for quit). Once the loop is done, the program will display the robot's final position and the total distance it traveled. A typical output of the program including user interaction is provided below. Robot name: R2D2 Direction of move (x/y/q) : x Distance: 100 Direction of move (x/y/a): Y Distance: 50 Direction of move (x/Vax Distance: -20 Direction of move (x/a) R2D2 is now at position 89,5e and traveled a total of 170 units

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!