Update Product.cs
This commit is contained in:
parent
f8ffe9c7aa
commit
05406dafc8
1 changed files with 2 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Supermarket;
|
namespace Supermarket;
|
||||||
|
|
||||||
public abstract class Product
|
public abstract class Product
|
||||||
{
|
{
|
||||||
|
|
@ -106,11 +106,7 @@ public abstract class Product
|
||||||
weight += i % 2 == 0 ? digit * evenWeight : digit * oddWeight;
|
weight += i % 2 == 0 ? digit * evenWeight : digit * oddWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
int calculatedCheckDigit = 10 - (weight % 10);
|
int calculatedCheckDigit = 10 - (weight % 10) % 10;
|
||||||
if (calculatedCheckDigit == 10)
|
|
||||||
{
|
|
||||||
calculatedCheckDigit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return calculatedCheckDigit == int.Parse(barcode[^1].ToString());
|
return calculatedCheckDigit == int.Parse(barcode[^1].ToString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue