Factories

Report a typo

What will be the output of the following snippet of code?

fun main() {
    val factory = FactoryWithRoof(3, 2, 23000)
    print(factory.employeesPerFloor())
}

open class Facility(val floors: Byte) {
    fun addFloors(num: Byte): Int = floors + num
}

open class Factory(floors: Byte, val employees: Short, val roof: Byte) : Facility(floors) {
    fun buildRoof(): Int = super.addFloors(roof)
    open fun employeesPerFloor(): Int = employees / floors
}

open class FactoryWithRoof(floors: Byte, roof: Byte, employees: Short) : Factory(floors, employees, roof) {
    override fun employeesPerFloor(): Int = employees / (floors + super.buildRoof())
}
Enter a number
___

Create a free account to access the full topic