Update Product.cs

This commit is contained in:
MarcUs7i 2025-03-20 08:16:51 +02:00 committed by GitHub
parent f8ffe9c7aa
commit 05406dafc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
namespace Supermarket;
namespace Supermarket;
public abstract class Product
{
@ -106,11 +106,7 @@ public abstract class Product
weight += i % 2 == 0 ? digit * evenWeight : digit * oddWeight;
}
int calculatedCheckDigit = 10 - (weight % 10);
if (calculatedCheckDigit == 10)
{
calculatedCheckDigit = 0;
}
int calculatedCheckDigit = 10 - (weight % 10) % 10;
return calculatedCheckDigit == int.Parse(barcode[^1].ToString());
}