Question: 2 Consider the Vector 2 D class. We want to add multiplication methods in this class. If a vector is multiplied by a real number,

2 Consider the Vector2D class.
We want to add multiplication methods in this class. If a vector is multiplied by a real number, then
both x and y values are simply multiplied by that real number. If it is multiplied by another vector
v, then it will follow the rule of dot product. Dot product of two vectors u&v,u.v=u.x**v.x+
u. Y ?**.y. In this Vector2D class, write two overloaded methods for multiplication;
A. One method takes a double parameter, does the real number multiplication, then returns a
Vector 2D object and
B. The other one takes a Vector2D parameter, does the dot product and then returns a double
number.
public class Vector2D{
double x,y;
Vector2D()1
x=0;
y=0;
}
Vector2D(double x, double y)
this. x=x;
this. y=y i
}
}
 2 Consider the Vector2D class. We want to add multiplication methods

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!