Created
August 2, 2009 13:07
-
-
Save takedasoft/160086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rubynizer(n:Any) { | |
def to_s = n.toString | |
def to_i = { | |
if( n.isInstanceOf[Char] ) n.asInstanceOf[Char].toString.toInt | |
else if( n.isInstanceOf[String] ) n.asInstanceOf[String].toInt | |
else throw new NumberFormatException() | |
} | |
} | |
class Bakanizer(n:Int) { | |
implicit def rubynize(n:Any) = new Rubynizer(n) | |
def ! = baka(n) | |
private def baka(n: Int): String = { | |
if( n < 10 ) if( n % 3 == 0 ) ichi(n) else n.to_s | |
else if( n < 99 ){ | |
val s = n.to_s | |
val k2 = s(0).to_i | |
val k1 = s(1).to_i | |
if( n % 3 == 0 || k2 == 3 || k1 == 3 ) ju(k2) + ichi(k1) | |
else s | |
}else throw new Exception("2桁まで") | |
} | |
private val ju:List[String] | |
= List("","じゅ~","に~じゅ","さぁ~んじゅ","よぉ~んじゅ" | |
,"ごぉ~じゅ","ろぉくじゅ","しぃちじゅ","はぁ~ちじゅ","きゅ~じゅ") | |
private val ichi:List[String] | |
= List("","えぃち","にぃ","さぁん","しぃ","ごぉ" | |
,"ろぉく","ひぃち","はぁち","きゅ~") | |
} | |
class NiceGuy(s:java.lang.String) { | |
def さん = new NiceGuy(s) | |
def ありがとう = s match{ | |
case "まっちゃ" => throw new ノーサンキューまっちゃだいふくモゾがゆいわよException() | |
case _ => s + "さん曰く「どういたしまして!」" | |
} | |
class ノーサンキューまっちゃだいふくモゾがゆいわよException extends Exception{ | |
} | |
} | |
implicit def bakanize(n: Int) = new Bakanizer(n) | |
implicit def foo(s:java.lang.String) = new NiceGuy(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment