Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

billions and millions greater than 2 #630

Closed
wants to merge 2 commits into from
Closed

billions and millions greater than 2 #630

wants to merge 2 commits into from

Conversation

rafael-bianchi
Copy link

@rafael-bianchi rafael-bianchi commented Apr 27, 2017

Billions and millions (plural) were only working when the number was greater than 2.
E.g.
1 milhão
2 milhão
3 milhões

Here is a checklist you should tick through before submitting a pull request:

  • Implementation is clean
  • Code adheres to the existing coding standards; e.g. no curlies for one-line blocks, no redundant empty lines between methods or code blocks, spaces rather than tabs, etc.
  • No ReSharper warnings
  • There is proper unit test coverage
  • If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution
  • There are very few or no comments (because comments shouldn't be needed if you write clean code)
  • Xml documentation is added/updated for the addition/change
  • Your PR is (re)based on top of the latest commits from the dev branch (more info below)
  • Link to the issue(s) you're fixing from your PR description. Use fixes #<the issue number>
  • Readme is updated if you change an existing feature or add a new one
  • Run either build.cmd or build.ps1 and ensure there are no test failures

Billions and millions (plural) were only working when the number was greater than 2.
E.g.
1 milhão
2 milhão
3 milhões
@clairernovotny
Copy link
Member

Thanks! Can you please update the unit test to account for this?

@@ -26,7 +26,7 @@ public override string Convert(int number, GrammaticalGender gender)
if ((number / 1000000000) > 0)
{
// gender is not applied for billions
parts.Add(number / 1000000000 > 2
parts.Add(number / 1000000000 == 1
? string.Format("{0} bilhões", Convert(number / 1000000000, GrammaticalGender.Masculine))
: string.Format("{0} bilhão", Convert(number / 1000000000, GrammaticalGender.Masculine)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use interpolated string:

var genderMark = number / 1000000000 == 1 ? "ões" : "ão";
parts.Add($"{Convert(number / 1000000000, GrammaticalGender.Masculine)} bilh{genderMark}");

And you can use something similar for millions (or even make it a private static method).

Copy link
Author

@rafael-bianchi rafael-bianchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added unit tests

@rafael-bianchi rafael-bianchi deleted the patch-1 branch April 27, 2017 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants