Untitled
Anonymous
scala
10/03/2021 2:00 PM
576 B
31
Indexable
object Hello extends App {
val element: Element = new UniformElement('#', 7, 7)
}
abstract class Element {
def contents: Array[String]
val height = contents.length
val width =
if (height == 0) 0 else contents(0).length
}
class UniformElement(
ch: Char,
override val width: Int,
override val height: Int
) extends Element {
private val line = ch.toString * width
def contents = Array.fill(height)(line)
}
Editor is loading...