24 lines
544 B
Kotlin
24 lines
544 B
Kotlin
|
package drills.drill01.exercise4
|
||
|
|
||
|
import drills.drill01.exercise2.PrintServiceImpl
|
||
|
import util.rmi.Client
|
||
|
|
||
|
fun main() {
|
||
|
Client(clientHandler).start()
|
||
|
}
|
||
|
|
||
|
val clientHandler = {
|
||
|
val math = Client.lookup("math") as Math
|
||
|
|
||
|
val sps = PrintServiceImpl("synchronous")
|
||
|
val aps = PrintServiceImpl("asynchronous")
|
||
|
|
||
|
println("Enter the number of which you want to calculate the factorial:")
|
||
|
val n = readLine()?.toInt() ?: 0
|
||
|
|
||
|
val fact = math.getFactOf(n)
|
||
|
sps.print("The factorial of $n is $fact")
|
||
|
|
||
|
math.getFactOf(n, aps)
|
||
|
}
|