RosettaCodeData/Task/Roman-numerals-Encode/Objeck/roman-numerals-encode.objeck
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

32 lines
724 B
Text

bundle Default {
class Roman {
nums: static : Int[];
rum : static : String[];
function : Init() ~ Nil {
nums := [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
rum := ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
}
function : native : ToRoman(number : Int) ~ String {
result := "";
for(i :=0; i < nums->Size(); i += 1;) {
while(number >= nums[i]) {
result->Append(rum[i]);
number -= nums[i];
};
};
return result;
}
function : Main(args : String[]) ~ Nil {
Init();
ToRoman(1999)->PrintLine();
ToRoman(25)->PrintLine();
ToRoman(944)->PrintLine();
}
}
}