JavaOOP/lab_4/Furniture.kt

15 lines
675 B
Kotlin
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package lab_4
class Furniture(val name: String, val material: String, val price: Int, private val length: Int, private val width: Int, private val height: Int) {
fun print(nameWidth: Int, materialWidth: Int, priceWidth: Int){
val printString = StringBuilder()
printString
// .append("Furniture stats: {")
.append("Name: ${this.name.padEnd(nameWidth)} ")
.append("Material: ${this.material.padEnd(materialWidth)} ")
.append("Price: ${(this.price.toString() + " cu").padEnd(priceWidth + 3)} ")
.append("Size: ${this.length}×${this.width}×${this.height}")
println(printString)
}
}