Question: * use java * Imagine yourself as an astronaut ( represented as 3 D vector ) on a space mission to explore a distant galaxy.
use javaImagine yourself as an astronaut represented as D vector on a space
mission to explore a distant galaxy. As you navigate through space, you will
encounter various celestial bodies represented as D vectors. Your mission is
to perform vector operations to reach your destination. Let me to guide you
on how to solve the problem:
In the class VectorD define the components of the vector ie xy
z It is necessary to encapsulate your data since a client program,
SpaceMission, will use this class later.
Implement the methods provided in the UML diagram below for the
VectorD class. These methods cover the fundamental vector
operations.
Now you should implement the SpaceMission class from scratch based
on the provided UML diagram.
The instance variable of this class shows your position in the space.
Now, you have identified an interesting celestial body that you wish to
travel to To assess its feasibility, follow the steps below:
i First, measure the distance between your current position
and the location of the celestial body, which is represented
by another vector. For this, Implement
distanceTo VectorD method.
ii To facilitate travel, there are instances where you need to
refuel by certain amounts. This process involves vector
scalar multiplication. When a vector is multiplied by a
scalar, the length magnitude of the vector increases
proportionally to the scalar factor. To achieve this,
implement the method refuel double in which you must
use scalarMultiplication as defined in the VectorD
class.
iii. Now, use the two methods mentioned above to implement
navigate VectorD double, double This function
checks the distance to the specified celestial body. If the
distance is more than or equal to the provided threshold,
you reposition yourself to where the celestial body is If
not, you repeatedly refuel yourself by the given refuel
amount until the distance is more than or equal to the
provided threshold. At this point, you reposition yourself.
Please note that, as the JavaDoc explains, the first input
parameter represents the position of the celestial body,
the second is the threshold, and the third is the amount by
which you refuel yourself.
Please note that, as usual, the signature of the method should not change if
it is given. If it is not provided, then the signature should match what is
given in the JUnit test cases.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
