class Cowsay {
static say(message) {
var lines = message.split("\n")
var maxWidth = 0
// Find the longest line to determine the bubble width
for (line in lines) {
if (line.count > maxWidth) maxWidth = line.count
}
var top = " " + ("_" * (maxWidth + 2))
var bottom = " " + ("-" * (maxWidth + 2))
System.print(top)
if (lines.count == 1) {
System.print("< %(lines[0]) >")
} else {
for (i in 0...lines.count) {
var line = lines[i]
var padding = " " * (maxWidth - line.count)
var border = ""
if (i == 0) {
border = "/ "
padding = padding + " \\"
} else if (i == lines.count - 1) {
border = "\\ "
padding = padding + " /"
} else {
border = "| "
padding = padding + " |"
}
System.print(border + line + padding)
}
}
System.print(bottom)
System.print(" \\ ^__^")
System.print(" \\ (oo)\\_______")
System.print(" (__)\\ )\\/\\")
System.print(" ||----w |")
System.print(" || ||")
}
}
// Test it out
Cowsay.say("wow i like wren")