forked from kontur-courses/clean-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kontur-courses#4 from kontur-courses/OneMoreContro…
…lDigit One more control digit
- Loading branch information
Showing
30 changed files
with
510 additions
and
300 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace ControlDigit | ||
{ | ||
public static class Isbn13Extensions | ||
{ | ||
public static int CalculateIsbn13(this long number) | ||
{ | ||
int sum = 0; | ||
int factor = 1; | ||
do | ||
{ | ||
int digit = (int)(number % 10); | ||
sum += factor * digit; | ||
factor = 4 - factor; | ||
number /= 10; | ||
} | ||
while (number > 0); | ||
int m = sum % 10; | ||
if (m == 0) | ||
return 0; | ||
return 10 - m; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace ControlDigit | ||
{ | ||
public static class SnilsExtensions | ||
{ | ||
public static int CalculateSnils(this long number) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using NUnit.Framework; | ||
|
||
namespace ControlDigit | ||
{ | ||
[TestFixture] | ||
public class SnilsExtensions_Tests | ||
{ | ||
[TestCase(1, ExpectedResult = 1)] | ||
[TestCase(10, ExpectedResult = 2)] | ||
[TestCase(100, ExpectedResult = 3)] | ||
[TestCase(1001, ExpectedResult = 4 + 1)] | ||
[TestCase(1111, ExpectedResult = 4 + 3 + 2 + 1)] | ||
[TestCase(112233445, ExpectedResult = 95)] | ||
[TestCase(87654303, ExpectedResult = 0)] | ||
[TestCase(87654302, ExpectedResult = 0)] | ||
[TestCase(116973385, ExpectedResult = 89)] | ||
[TestCase(152675138, ExpectedResult = 70)] | ||
[TestCase(463436384, ExpectedResult = 96)] | ||
[TestCase(158757369, ExpectedResult = 28)] | ||
[TestCase(192168000, ExpectedResult = 62)] | ||
public int Snils(long x) | ||
{ | ||
return x.CalculateSnils(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace ControlDigit | ||
{ | ||
public static class UpcExtensions | ||
{ | ||
public static int CalculateUpc(this long number) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.