Adding Method Displayer, and renaming projects
This commit is contained in:
65
MethodLibrary/Basic.cs
Normal file
65
MethodLibrary/Basic.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace MethodLibrary
|
||||
{
|
||||
public class Basic : IMethodCollection
|
||||
{
|
||||
public void DisplayAllMethods()
|
||||
{
|
||||
Console.WriteLine($"AddAndMultiply: {AddAndMultiply(2, 4, 5)}");
|
||||
Console.WriteLine($"CToF(0): {CtoF(0)}");
|
||||
Console.WriteLine($"CToF(100): {CtoF(100)}");
|
||||
Console.WriteLine($"CToF(-300): {CtoF(-300)}");
|
||||
Console.WriteLine($"ElementaryOperations(3, 8): {string.Join(", ", ElementaryOperations(3, 8))}");
|
||||
Console.WriteLine($"IsResultTheSame(2+2, 2*2): {IsResultTheSame(2 + 2, 2 * 2)}");
|
||||
Console.WriteLine($"IsResultTheSame(9/3, 16-1): {IsResultTheSame(9 / 3, 16 - 1)}");
|
||||
Console.WriteLine($"ModuloOperations(8, 5, 2): {ModuloOperations(8, 5, 2)}");
|
||||
Console.WriteLine($"CubeOf(2): {CubeOf(2)}");
|
||||
Console.WriteLine($"CubeOf(-5.5): {CubeOf(-5.5)}");
|
||||
Console.WriteLine($"SwapTwoNumbers(87, 45): {string.Join(", ", SwapTwoNumbers(87, 45))}");
|
||||
Console.WriteLine($"SwapTwoNumbers(-13, 2): {string.Join(", ", SwapTwoNumbers(-13, 2))}");
|
||||
}
|
||||
|
||||
public int AddAndMultiply(int a, int b, int c)
|
||||
{
|
||||
return (a + b) * c;
|
||||
}
|
||||
|
||||
public string CtoF(int celcius)
|
||||
{
|
||||
if (celcius <= -271.15)
|
||||
return "Temperature below absolute zero!";
|
||||
|
||||
double fahrenheit = (celcius * 1.8) + 32;
|
||||
|
||||
return $"T = {fahrenheit}F";
|
||||
}
|
||||
|
||||
public List<double> ElementaryOperations(double a, double b)
|
||||
{
|
||||
List<double> retval = [a + b, a - b, a * b];
|
||||
if (a > 0 && b > 0)
|
||||
retval.Add(a / b);
|
||||
|
||||
return retval;
|
||||
}
|
||||
public bool IsResultTheSame(double a, double b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
public int ModuloOperations(int a, int b, int c)
|
||||
{
|
||||
return a % b % c;
|
||||
}
|
||||
|
||||
public double CubeOf(double a)
|
||||
{
|
||||
return a * a * a;
|
||||
}
|
||||
|
||||
public List<int> SwapTwoNumbers(int a, int b)
|
||||
{
|
||||
return [b, a];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user