Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed
image text in transcribed
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 getyPosition() getter; returns the current y position of the robot 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 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/9): X Distance: 100 Direction of move (x/y/9): Y Distance: 50 Direction of move (x/y/4): * Distance: 20 Direction of move (x/y/9): 9 R2D2 is now at position ( 80, 50 ) and traveled a total of 170 units Requirements course. Your source code should abide by the Java programming standards for the Your source code should be documented using Javadoc style according to the course standards. Use the default package in your project; do not specify a package in your code. Use any file and class names specified in the assignment, Preparation for submission: After you have completed the program, put all of the java the files (Prog3.java and Robot.java) into a zip file named YourLastName3.zip. The zip file should have no subdirectory structure

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions