We need to perform below task
Define a Class Rectangle
. Class Rectangle
has a constructor taking two integer parameters, length
and breadth
. It has two functions area
and perimeter
which calculate the respective parameters for the Rectangle
object created. Next, the object RectangleDemo
takes two inputs which are the length and breadth of the rectangle. Create a rectangle object with these two methods and call the two functions to print the area and perimeter of rectangle.
for which written below code , please let us know issue with it as it throwing error -
class Rectangle{
int a = input1;
int b = input2;
def Area() = a* b
def Perimeter() = (a + b) / 2
}
object RectangleDemo extends App{
val input1 :Int = args(0).toInt
val input2 :Int = args(1).toInt
var variable = new Variables(input1, input2)
println(variable.Area())
println(variable.Perimeter())
}