Structure because structure

This commit is contained in:
Mira 2023-06-16 14:20:32 +02:00
parent 01d1ea3573
commit 2b2a53466f
Signed by untrusted user who does not match committer: Xorog
GPG key ID: 983798ED9C3E7C36
17 changed files with 693 additions and 674 deletions

20
Tools/MathTools.cs Normal file
View file

@ -0,0 +1,20 @@
namespace Xorog.UniversalExtensions;
public static class MathTools
{
/// <summary>
/// Calculates the percentage of the given 2 values.
/// </summary>
/// <param name="current">The current value.</param>
/// <param name="max">The maximum value.</param>
/// <returns>The percentage.</returns>
/// <exception cref="ArgumentException"></exception>
public static int CalculatePercentage(double current, double max)
{
if (max == 0)
throw new ArgumentException("Max cannot be zero.");
double percentage = (current / max) * 100;
return Convert.ToInt32(percentage);
}
}