Infix operator

Report a typo

Implement two operators: * and *: for the Point class. The * method takes the right operand an integer number and multiplies each coordinate of the Point class by this number. The method *: does the same but takes the left operand.

Make sure that the following code compiles:

3 *: Point(1, 2, 3) // Point(3, 6, 9)

Point(1, 2, 3) * 3 // Point(3, 6, 9)

Sample Input 1:

Point(1, 2, 3) 3

Sample Output 1:

Point(3, 6, 9)
Point(3, 6, 9)
Write a program in Scala 3
class Point(val x: Int, val y: Int, val z: Int):
/* your code */
___

Create a free account to access the full topic