Question: Language: Scala create a Scala class named PhysicsVector with the following: A constructor that takes 3 variables of type Double named x, y, and z.
Language: Scala
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
