https://github.com/hazzik/currencytowords
https://github.com/hazzik/currencytowords
assignment
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hazzik/currencytowords
- Owner: hazzik
- Created: 2020-08-27T03:09:33.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-27T05:51:10.000Z (over 4 years ago)
- Last Synced: 2024-11-28T12:32:00.612Z (6 months ago)
- Topics: assignment
- Language: C#
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Currency to Words
The library provides two extension methods:
1. `NumberToWordExtensions.ToWords` to convert a number into its form written out in English words
2. `CurrencyToWords.CurrencyToWords` to convert a number into a dollar written out in English wordsThe function accepts numbers between 0 and 1000. It throws an ArgumentException if these preconditions are not met.
The fractional cents are ignored (eg. 0.003 would be translated to "zero dollars")
Only English language is supported and currency is assumed to be called dollars its fraction -- cents.
# Notes
The library was written in a TDD (test-first) manner with small implementation steps.
If you explore the commit history you can get a rough idea how I was thinking and what small steps were taken to implement the solution.
Because this is a test task, it was implemented in a way that I did not use any external libraries.
In the real world I would be using the [Humanizer](https://github.com/Humanizr/Humanizer) library and would not implement inflections or `ToWords` method myself.