-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path24.kts
More file actions
19 lines (19 loc) · 809 Bytes
/
24.kts
File metadata and controls
19 lines (19 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
fun main(){
val rect = Rectangle(5.0)
val circle = Circle(3.0)
val triangle=Triangle(7.0,7.0,7.0)
val maxAreaRectAndCircle=maxArea(rext,circle)
val maxAreaRectCircleTriangle=maxArea(rect,circle,triangle)
println("the maximum area of rectangle and the circle is $maxAreaRectAndCircle")
println("the maximum area of rectangle, the circle and triangle is $maxAreaRectCircleTriangle")
}
fun maxArea(shape1:Shape,shape2:Shape):Double{
val areaShape1=shape1.area()
val areaShape2=shape2.area()
return if(areaShape1>areaShape2) areaShape1 else areaShape2
}
fun maxArea(shape1:Shape,shape2:Shape,shape3:Shape):Double{
val maxAreaShape1Shape2=maxArea(shape1,shape2)
val areaShape3=shape3.area()
return if(maxAreaShape1Shape2>areaShape3) maxAreaShape1Shape2 else areaShape3
}