Question: LANGUAGE SCALA ONLY TESTING PART NEEDED create a Scala class named PhysicsVector with the following: A constructor that takes 3 variables of type Double named

LANGUAGE SCALA

ONLY TESTING PART NEEDED

"create a Scala class named PhysicsVector with the following: A constructor that takes 3 variables of type Double named x, y, and z. A method named multiplyByConstant that takes a Double and returns Unit. This method multiplies x, y, and z by the input. Be sure to update the state variables of the object when this method is called. Example: if a vector with x, y, and z of (2.0, 0.0, -1.5) has multiplyByConstant(2.0) called on it, its state will become (4.0, 0.0,-3.0). A method named addVector that takes a PhysicsVector and returns Unit. This method adds the values of x, y, and z of the input vector to the state variable of the calling vector. Example: If a vector with x, y, and z of (2.0, 0.0, -1.5) has addVector(otherVector) called on it where otherVector is (-3.5, 0.4, -1.0), its state will become (-1.5, 0.4, -2.5).

Testing: In a package named tests" create a Scala class named "TestVector" as a test suite that tests all the functionality listed above.

Sample Usage Note Both methods for this question return Unit. To test these methods, you can access the state variables of the calling object after the method resolves. Since we're checking Doubles, be sure to allow enough tolerance to cover truncation errors.

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!