diff --git a/84 Super Star Trek/csharp/Random.cs b/84 Super Star Trek/csharp/Random.cs index ae51d95b..cd0ef230 100644 --- a/84 Super Star Trek/csharp/Random.cs +++ b/84 Super Star Trek/csharp/Random.cs @@ -4,7 +4,7 @@ namespace SuperStarTrek { internal class Random { - private static readonly System.Random _random = new(); + private readonly System.Random _random = new(); internal Coordinates GetCoordinate() => new Coordinates(Get1To8Inclusive() - 1, Get1To8Inclusive() - 1); diff --git a/84 Super Star Trek/csharp/Resources/Strings.cs b/84 Super Star Trek/csharp/Resources/Strings.cs index fea41521..72fd7d5a 100644 --- a/84 Super Star Trek/csharp/Resources/Strings.cs +++ b/84 Super Star Trek/csharp/Resources/Strings.cs @@ -35,9 +35,7 @@ namespace SuperStarTrek.Resources private static string GetResource([CallerMemberName] string name = "") { var streamName = $"SuperStarTrek.Resources.{name}.txt"; - using var stream = Assembly - .GetExecutingAssembly() - .GetManifestResourceStream(streamName); + using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(streamName); using var reader = new StreamReader(stream); return reader.ReadToEnd(); diff --git a/84 Super Star Trek/csharp/Space/Coordinates.cs b/84 Super Star Trek/csharp/Space/Coordinates.cs index 4c4f7b69..4bcc8085 100644 --- a/84 Super Star Trek/csharp/Space/Coordinates.cs +++ b/84 Super Star Trek/csharp/Space/Coordinates.cs @@ -21,7 +21,7 @@ namespace SuperStarTrek.Space internal int RegionIndex { get; } internal int SubRegionIndex { get; } - private int Validated(int value, string argumentName) + private static int Validated(int value, string argumentName) { if (value >= 0 && value <= 7) { return value; } diff --git a/84 Super Star Trek/csharp/Space/Course.cs b/84 Super Star Trek/csharp/Space/Course.cs index a46385c3..7067ec81 100644 --- a/84 Super Star Trek/csharp/Space/Course.cs +++ b/84 Super Star Trek/csharp/Space/Course.cs @@ -74,7 +74,7 @@ namespace SuperStarTrek.Space return (xComplete && yComplete, new Coordinates(quadrantX, quadrantY), new Coordinates(sectorX, sectorY)); } - private (bool, int, int) GetNewCoordinate(int quadrant, int sector, float sectorsTravelled) + private static (bool, int, int) GetNewCoordinate(int quadrant, int sector, float sectorsTravelled) { var galacticCoordinate = quadrant * 8 + sector + sectorsTravelled; var newQuadrant = (int)(galacticCoordinate / 8); diff --git a/84 Super Star Trek/csharp/Space/Galaxy.cs b/84 Super Star Trek/csharp/Space/Galaxy.cs index 8fce8fb9..66f7c418 100644 --- a/84 Super Star Trek/csharp/Space/Galaxy.cs +++ b/84 Super Star Trek/csharp/Space/Galaxy.cs @@ -11,7 +11,6 @@ namespace SuperStarTrek.Space private static readonly string[] _regionNames; private static readonly string[] _subRegionIdentifiers; private readonly QuadrantInfo[][] _quadrants; - private readonly Random _random; static Galaxy() { @@ -21,8 +20,6 @@ namespace SuperStarTrek.Space internal Galaxy(Random random) { - _random = random; - _quadrants = Enumerable .Range(0, 8) .Select(x => Enumerable diff --git a/84 Super Star Trek/csharp/Utils/DirectionAndDistance.cs b/84 Super Star Trek/csharp/Utils/DirectionAndDistance.cs index 65cb6a30..e4b1a2fa 100644 --- a/84 Super Star Trek/csharp/Utils/DirectionAndDistance.cs +++ b/84 Super Star Trek/csharp/Utils/DirectionAndDistance.cs @@ -45,7 +45,7 @@ namespace SuperStarTrek.Utils // 8430 PRINT"DIRECTION =";C1+(((ABS(X)-ABS(A))+ABS(X))/ABS(X)):GOTO8460 // 8450 PRINT"DIRECTION =";C1+(ABS(X)/ABS(A)) // 8460 PRINT"DISTANCE =";SQR(X^2+A^2):IFH8=1THEN1990 - private float GetDirection(float deltaX, float deltaY) + private static float GetDirection(float deltaX, float deltaY) { var deltaXDominant = Math.Abs(deltaX) > Math.Abs(deltaY); var fractionalPart = deltaXDominant ? deltaY / deltaX : -deltaX / deltaY; @@ -59,7 +59,7 @@ namespace SuperStarTrek.Utils return direction < 1 ? direction + 8 : direction; } - private float GetDistance(float deltaX, float deltaY) => + private static float GetDistance(float deltaX, float deltaY) => (float)Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)); } } \ No newline at end of file