= Solution
Convert lowercase alphabet letters before passing them to the next implementation. Already uppercase letters and other characters pass through unchanged.
``
trait CapitalisePlugIn extends Doc {
abstract override def insert(x: Char, pos: Int): Unit = {
val y = if ('a' <= x && x <= 'z') ('A' + (x - 'a')).toChar else x
super.insert(y, pos)
}
}
``
The character conversion uses the paper's contiguous lowercase and uppercase Latin ranges. Thus
$$
\boxed{\texttt{insert('a',pos)}\text{ delegates as }\texttt{insert('A',pos)}.}
$$
Deletion, reading, and size need no overrides.
Back to article page