Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The objectives of this assignment are to 1. Gain a further understanding and experience in the use of the Eclipse IDE for Java. 2. Gain
The objectives of this assignment are to 1. Gain a further understanding and experience in the use of the Eclipse IDE for Java. 2. Gain a further understanding of the basic definition and use of objects including class definition, constructors, instance variables, and methods. Gain a further understanding of developing a program to test the Java classes Create a class Robot. The robot moves around in a Cartesian coordinate system and can only y position, and total distance traveled. Implement the following constructor and methods: 3. move in only one direction (either x or y, but not both) at a time. A robot has a name, x position Robot (String name) constructor that sets the name instance variable and initializes the remaining instance variables to locate the robot at coordinate (0. 0) getName() getXPosition() getyPosition() moveX(int distance) getter; returns a String containing the robot name getter; returns the current x position of the robot getter, returns the current y position of the robot adjusts the x position by distance and adds the distance to the total distance traveled adjusts the y position by distance and adds the distance to the total distance traveled moveY (int distance) distanceTraveled () 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 q (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/q): y Distance: 50 Direction of move (x/y/q): x Distance: -28 Direction of move (x/y/q): q R2D2 is now at position (80, 50) and traveled a total of 178 units
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started