Implement Roman Calculator with clean code

74 views
Skip to first unread message

swaraj patil

unread,
Oct 14, 2016, 4:44:02 PM10/14/16
to Clean Code Discussion
Hi All,

I am learning clean code practices by implementing solution for different problem statements. I am going to implement solution for following problem statement - 

Problem Description

"As a Roman Bookkeeper I want to add Roman numbers because doing it manually is too tedious." Given the Roman numerals, (IVXLCDM which means one, five, ten, fifty, hundred, fivehundred and a thousand respectively), create two numbers and add them. As we are in Rome there is no such thing as decimals or int, we need to do this with the strings. An example would be "XIV" + "LX" = "LXXIV"

There are some rules to a Roman number:

  • Numerals can be concatenated to form a larger numeral ("XX" + "II" = "XXII")
  • If a lesser numeral is put before a bigger it means subtraction of the lesser from the bigger ("IV" means four, "CM" means ninehundred)
  • If the numeral is I, X or C you can't have more than three ("II" + "II" = "IV")
  • If the numeral is V, L or D you can't have more than one ("D" + "D" = "M")

 Rules for implementation

     1. Simple object oriented solution in any programming language

     2. Use TDD approach for unit testing

     3. Implement business logic for this. No fancy UI required


 I will share my solution once it is completed. If anyone interested to solve this problem, solve and share you solution as well. Sharing feedback on each other solution will be helpful for us improve as developer.


I think best way to learn clean code is write clean code to solve problem.

     

Thanks,

Swaraj





Reply all
Reply to author
Forward
0 new messages