Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Today we are going to use the Detector and UserShape class from Activity 5.3, Shapes and Games. You are going to create a simple intelligent

Today we are going to use the Detector and UserShape class from Activity 5.3, Shapes and Games.

You are going to create a simple intelligent program that drives a spaceship back to homebase. Remember how you created the spaceship.

 UserShape spaceShip = new UserShape(Detector.TRIANGLE, xCenter, yCenter, 50, 50); detector.addShape(spaceShip);

Steps:

Part 1:

Place spaceship in the middle of the screen. Get help if you need clarification.

Randomly place a "Point" representing the homebase. The point location should be far from the spaceship (i.e.; it cannot be touching the spaceship). Regenerate the point until it is in a different location.

UserShape point = new UserShape(Detector.CIRCLE, pointY, pointX, 10, 10); detector.addShape(point);

Automatically move the spaceship to this point representing the homebase. This is the intelligent program that we mentioned before. How should that happen? Note that you are not allowed to just "pop" the spaceship at the point location. It needs to travel to the location along the x and y axis. The following code moves up the spaceship by Observe also the other methods such as:

moveDown, moveLeft, moveRight.
detector.moveUp(1, 1, spaceShip);

The movements should result to the final destination which is the homebase. Once the spaceship is in the homebase ask the user to see whether she wants to repeat this process.

Repeat this process until the user wants to exit. The spaceship should not be reset after every loop, only the point should be randomly moved. So the resulting program should allow the user loop and see the spaceship travel around to the different points

Submission:

You need to create a Java program to do the above tasks. In addition, you need to add two parallel arrays to record the locations that the spaceship has gone through. That is an x array and a y array which holds the x and y's of the locations spaceship visited. Overwrite the same array in each iteration. Add a method to show the contents of the parallel arrays in pair format, for example (10, 20). Submit your code.

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago