* roman.st * * Implementation of the class Roman * * by Ricardo Szmit * * Last update: 04.04.94 Class Roman Object dict Methods Roman 'all' new dict <- Dictionary new. dict at:1 put:'I'; at:4 put:'IV'; at:5 put:'V'; at:9 put:'IX'; at:10 put:'X'; at:40 put:'XL'; at:50 put:'L'; at:90 put:'XC'; at:100 put:'C'; at:400 put:'CD'; at:500 put:'D'; at:900 put:'CM'; at:1000 put:'M' | generate: anInteger | count roman | count <- anInteger. roman <- ''. ( dict keys select: [ :k | k <= count ] ) sort reverseDo: [ :k | (count quo: k) timesRepeat: [ roman <- roman, ( dict at: k ) ]. count <- count rem: k ]. ^roman ]