progs/roman.scala
changeset 109 293ea84d82ca
parent 108 d39b8733c6ea
child 265 59779ce322a6
equal deleted inserted replaced
108:d39b8733c6ea 109:293ea84d82ca
   113 addromanfile("roman.txt")
   113 addromanfile("roman.txt")
   114 
   114 
   115 
   115 
   116 // Part 2 about Validation of Roman Numerals
   116 // Part 2 about Validation of Roman Numerals
   117 //===========================================
   117 //===========================================
       
   118 
       
   119 // (6) Write a function that validates roman numerals according
       
   120 // to the rules given in the CW.
       
   121 
       
   122 def isValidNumeral(digitList: RomanNumeral): Boolean =
       
   123 
       
   124 
       
   125 
       
   126 // some test cases
       
   127 val invalids = List("IXC", "XCX", "IIII", "IIIII", "DD", "VL", 
       
   128                     "MIM", "XXCIII", "LXXIIX", "IIIIX", "IIXX", 
       
   129                     "ICM", "CIM", "VIV", "IVX", "MCMC", "XIIX", "IIXX")
       
   130 
       
   131 val valids = List("IV", "VI", "IX", "MCMLXXIX", "MCMXLIV", "", "MDCLXI",
       
   132                   "MMMCMXCIX", "XLVIII", "MMVIII", "MMXI", "MCMLVI", "III",
       
   133                   "XXX", "CCC", "MMM", "VII", "LXVI", "CL", "MCC", "XC",
       
   134                   "MDCLXVI")
       
   135 
       
   136 // (7) Write a recursive function that converts an Integer into a
       
   137 // a roman numeral. The input will be between 0 and 3999.
       
   138 
       
   139 def Int2Roman(n: Int): RomanNumeral =
       
   140 
       
   141 // (8) Write a function that reads a text file containing valid and 
       
   142 // invalid roman numerals. Convert all valid roman numerals into integers, 
       
   143 // add them up and produce the result as a roman numeral (using the 
       
   144 // function in (7)
       
   145 
       
   146 def addvalidromanfile(filename: String) =
       
   147 
       
   148 // a test case
       
   149 //addvalidromanfile("roman2.txt")