diff --git a/.editorconfig b/.editorconfig index 3d9637a..8f46ac9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -94,9 +94,8 @@ csharp_style_namespace_declarations = file_scoped:warning dotnet_diagnostic.CS1591.severity = none dotnet_diagnostic.CA1062.severity = none +dotnet_diagnostic.CA1707.severity = none dotnet_diagnostic.CA1034.severity = none - - dotnet_diagnostic.CA2012.severity = none [/src/Lab5/ATM.Infrastructure.DataAccess/Migrations/*.cs] diff --git a/Directory.Packages.props b/Directory.Packages.props index 327678f..1af71ce 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,6 +9,7 @@ + diff --git a/src/Lab1/Environments/Cosmos.cs b/src/Lab1/Environments/Cosmos.cs new file mode 100644 index 0000000..eb6ae5a --- /dev/null +++ b/src/Lab1/Environments/Cosmos.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Environments; + +public class Cosmos : IEnvironment +{ + private readonly List _obstacles; + + public Cosmos(IEnumerable obstacles) + { + _obstacles = obstacles.ToList(); + } + + public Cosmos() + : this(Enumerable.Empty()) + { + } + + public TraversalResult TraverseEnvironment(IShip ship, int length) + { + foreach (ICosmosObstacle highDensityObstacle in _obstacles) + { + highDensityObstacle.GiveDamage(ship); + } + + EngineConsumption consumption = ship.DriveEngine.GetConsumption(length); + return new TraversalResult.Success(consumption.Time, new[] { consumption.Consumption }); + } + + public void AddObstacle(IObstacle obstacle) + { + if (obstacle is not ICosmosObstacle cosmosObstacle) + throw new ArgumentException("You can't add this obstacle to this environment."); + _obstacles.Add(cosmosObstacle); + } +} \ No newline at end of file diff --git a/src/Lab1/Environments/HighDensity.cs b/src/Lab1/Environments/HighDensity.cs new file mode 100644 index 0000000..080b538 --- /dev/null +++ b/src/Lab1/Environments/HighDensity.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles; +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Environments; + +public class HighDensity : IEnvironment +{ + private readonly List _obstacles; + + public HighDensity(IEnumerable obstacles) + { + _obstacles = obstacles.ToList(); + } + + public HighDensity() + : this(Enumerable.Empty()) + { + } + + public TraversalResult TraverseEnvironment(IShip ship, int length) + { + if (ship.JumpEngine == null || ship.JumpEngine.GetRange() < length) + return new TraversalResult.LostShip("Ship lost in a channel"); + + foreach (IHighDensityObstacle highDensityObstacle in _obstacles) + { + if (highDensityObstacle is AntimatterFlare && !ship.PhotonDeflector) + return new TraversalResult.DeathOfCrew(); + highDensityObstacle.GiveDamage(ship); + } + + EngineConsumption consumption = ship.JumpEngine.GetConsumption(length); + return new TraversalResult.Success(consumption.Time, new[] { consumption.Consumption }); + } + + public void AddObstacle(IObstacle obstacle) + { + if (obstacle is not IHighDensityObstacle highDensityObstacle) + throw new ArgumentException("You can't add this obstacle to this environment."); + _obstacles.Add(highDensityObstacle); + } +} \ No newline at end of file diff --git a/src/Lab1/Environments/IEnvironment.cs b/src/Lab1/Environments/IEnvironment.cs new file mode 100644 index 0000000..2135a40 --- /dev/null +++ b/src/Lab1/Environments/IEnvironment.cs @@ -0,0 +1,12 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Environments; + +public interface IEnvironment +{ + void AddObstacle(IObstacle obstacle); + + TraversalResult TraverseEnvironment(IShip ship, int length); +} \ No newline at end of file diff --git a/src/Lab1/Environments/NitrineNebula.cs b/src/Lab1/Environments/NitrineNebula.cs new file mode 100644 index 0000000..a706392 --- /dev/null +++ b/src/Lab1/Environments/NitrineNebula.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Environments; + +public class NitrineNebula : IEnvironment +{ + private readonly List _obstacles; + + public NitrineNebula(IEnumerable obstacles) + { + _obstacles = obstacles.ToList(); + } + + public NitrineNebula() + : this(Enumerable.Empty()) + { + } + + public TraversalResult TraverseEnvironment(IShip ship, int length) + { + if (ship.DriveEngine is not ExponentialDriveEngine) + return new TraversalResult.LostShip("The engines weren't powerful enough."); + + foreach (INitrineParticleObstacle x in _obstacles) + { + x.GiveDamage(ship); + } + + EngineConsumption consumption = ship.DriveEngine.GetConsumption(length); + return new TraversalResult.Success(consumption.Time, new[] { consumption.Consumption }); + } + + public void AddObstacle(IObstacle obstacle) + { + if (obstacle is not INitrineParticleObstacle nitrineParticleObstacle) + throw new ArgumentException("You can't add this obstacle to this environment."); + _obstacles.Add(nitrineParticleObstacle); + } +} \ No newline at end of file diff --git a/src/Lab1/Lab1.csproj b/src/Lab1/Lab1.csproj index 898ccf6..61dc2ed 100644 --- a/src/Lab1/Lab1.csproj +++ b/src/Lab1/Lab1.csproj @@ -2,6 +2,7 @@ Itmo.ObjectOrientedProgramming.Lab1 + true diff --git a/src/Lab1/Obstacles/AntimatterFlare.cs b/src/Lab1/Obstacles/AntimatterFlare.cs new file mode 100644 index 0000000..47c72cb --- /dev/null +++ b/src/Lab1/Obstacles/AntimatterFlare.cs @@ -0,0 +1,14 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles; + +public class AntimatterFlare : IHighDensityObstacle +{ + private const double Damage = 10; + + public void GiveDamage(IShip ship) + { + ship.TakeDamage(Damage); + } +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/Asteroid.cs b/src/Lab1/Obstacles/Asteroid.cs new file mode 100644 index 0000000..fade289 --- /dev/null +++ b/src/Lab1/Obstacles/Asteroid.cs @@ -0,0 +1,14 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles; + +public class Asteroid : ICosmosObstacle +{ + private const double Damage = 10; + + public void GiveDamage(IShip ship) + { + ship.TakeDamage(Damage); + } +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/CosmoWhale.cs b/src/Lab1/Obstacles/CosmoWhale.cs new file mode 100644 index 0000000..a51447a --- /dev/null +++ b/src/Lab1/Obstacles/CosmoWhale.cs @@ -0,0 +1,21 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles; + +public class CosmoWhale : INitrineParticleObstacle +{ + private const double Damage = 200; + private readonly int _population; + + public CosmoWhale(int population) + { + _population = population; + } + + public void GiveDamage(IShip ship) + { + if (!ship.AntiNitrineEmitter) + ship.TakeDamage(Damage * _population); + } +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/Interfaces/ICosmosObstacle.cs b/src/Lab1/Obstacles/Interfaces/ICosmosObstacle.cs new file mode 100644 index 0000000..5105581 --- /dev/null +++ b/src/Lab1/Obstacles/Interfaces/ICosmosObstacle.cs @@ -0,0 +1,5 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; + +public interface ICosmosObstacle : IObstacle +{ +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/Interfaces/IHighDensityObstacle.cs b/src/Lab1/Obstacles/Interfaces/IHighDensityObstacle.cs new file mode 100644 index 0000000..51f7ec5 --- /dev/null +++ b/src/Lab1/Obstacles/Interfaces/IHighDensityObstacle.cs @@ -0,0 +1,5 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; + +public interface IHighDensityObstacle : IObstacle +{ +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/Interfaces/INitrineParticleObstacle.cs b/src/Lab1/Obstacles/Interfaces/INitrineParticleObstacle.cs new file mode 100644 index 0000000..312d3c2 --- /dev/null +++ b/src/Lab1/Obstacles/Interfaces/INitrineParticleObstacle.cs @@ -0,0 +1,5 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; + +public interface INitrineParticleObstacle : IObstacle +{ +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/Interfaces/IObstacle.cs b/src/Lab1/Obstacles/Interfaces/IObstacle.cs new file mode 100644 index 0000000..7d7dbe9 --- /dev/null +++ b/src/Lab1/Obstacles/Interfaces/IObstacle.cs @@ -0,0 +1,8 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; + +public interface IObstacle +{ + void GiveDamage(IShip ship); +} \ No newline at end of file diff --git a/src/Lab1/Obstacles/Meteorite.cs b/src/Lab1/Obstacles/Meteorite.cs new file mode 100644 index 0000000..bf69004 --- /dev/null +++ b/src/Lab1/Obstacles/Meteorite.cs @@ -0,0 +1,14 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Obstacles; + +public class Meteorite : ICosmosObstacle +{ + private const double Damage = 10; + + public void GiveDamage(IShip ship) + { + ship.TakeDamage(Damage); + } +} \ No newline at end of file diff --git a/src/Lab1/Router/Path.cs b/src/Lab1/Router/Path.cs new file mode 100644 index 0000000..38946db --- /dev/null +++ b/src/Lab1/Router/Path.cs @@ -0,0 +1,21 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Environments; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Router; + +public class Path +{ + private readonly IEnvironment _environment; + private readonly int _length; + + public Path(IEnvironment environment, int length) + { + _environment = environment; + _length = length; + } + + public TraversalResult TraversePath(IShip ship) + { + return _environment.TraverseEnvironment(ship, _length); + } +} \ No newline at end of file diff --git a/src/Lab1/Router/Route.cs b/src/Lab1/Router/Route.cs new file mode 100644 index 0000000..2fa1210 --- /dev/null +++ b/src/Lab1/Router/Route.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Linq; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Router; + +public class Route +{ + private readonly List _paths; + + public Route(IEnumerable paths) + { + _paths = paths.ToList(); + } + + public TraversalResult Traverse(IShip ship) + { + int time = 0; + List fuels = new(); + + foreach (TraversalResult result in _paths.Select(path => path.TraversePath(ship))) + { + if (result is not TraversalResult.Success success) + return result; + time += success.Time; + fuels.AddRange(success.Fuel); + } + + return new TraversalResult.Success(time, fuels); + } +} \ No newline at end of file diff --git a/src/Lab1/Router/TraversalResult.cs b/src/Lab1/Router/TraversalResult.cs new file mode 100644 index 0000000..24ee351 --- /dev/null +++ b/src/Lab1/Router/TraversalResult.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Router; + +public abstract record TraversalResult +{ + public record Success(int Time, IEnumerable Fuel) : TraversalResult; + + public record LostShip(string Reason) : TraversalResult; + + public record DeathOfCrew : TraversalResult; + + public record DestroyedShip : TraversalResult; +} \ No newline at end of file diff --git a/src/Lab1/Services/FuelExchange.cs b/src/Lab1/Services/FuelExchange.cs new file mode 100644 index 0000000..5c2341e --- /dev/null +++ b/src/Lab1/Services/FuelExchange.cs @@ -0,0 +1,11 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Services; + +public static class FuelExchange +{ + public static double GetFuelPrice(Fuel fuel) + { + return fuel.Amount * fuel.Rarity; + } +} \ No newline at end of file diff --git a/src/Lab1/Services/PathFinder.cs b/src/Lab1/Services/PathFinder.cs new file mode 100644 index 0000000..2c15e5d --- /dev/null +++ b/src/Lab1/Services/PathFinder.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Services.Strategies; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Services; + +// This class should calculate all the traversal results, and pass them on to the strategy to decide what ship is best for the task. +public class PathFinder +{ + private readonly IPathFindingStrategy _strategy; + + public PathFinder(IPathFindingStrategy strategy) + { + _strategy = strategy; + } + + public PathFinderResult SelectShip(Route route, IEnumerable ships) + { + List> results = new(); + + results.AddRange(ships.Select(ship => new Tuple(ship, route.Traverse(ship)))); + + return _strategy.GetBestShip(results); + } +} \ No newline at end of file diff --git a/src/Lab1/Services/PathFinderResult.cs b/src/Lab1/Services/PathFinderResult.cs new file mode 100644 index 0000000..175ce08 --- /dev/null +++ b/src/Lab1/Services/PathFinderResult.cs @@ -0,0 +1,10 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Services; + +public abstract record PathFinderResult +{ + public record Success(IShip Ship) : PathFinderResult; + + public record Failed : PathFinderResult; +} \ No newline at end of file diff --git a/src/Lab1/Services/Strategies/BestPriceStrategy.cs b/src/Lab1/Services/Strategies/BestPriceStrategy.cs new file mode 100644 index 0000000..64dec61 --- /dev/null +++ b/src/Lab1/Services/Strategies/BestPriceStrategy.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Services.Strategies; + +public class BestPriceStrategy : IPathFindingStrategy +{ + public PathFinderResult GetBestShip(IEnumerable> results) + { + var possibleChoice = new List>(); + + foreach (Tuple result in results) + { + if (result.Item2 is not TraversalResult.Success success) + continue; + + double price = success.Fuel.Sum(FuelExchange.GetFuelPrice); + IShip ship = result.Item1; + + possibleChoice.Add(new Tuple(ship, price)); + } + + Tuple? bestChoice = possibleChoice.MinBy(t => t.Item2); + + if (bestChoice is null) + return new PathFinderResult.Failed(); + return new PathFinderResult.Success(bestChoice.Item1); + } +} \ No newline at end of file diff --git a/src/Lab1/Services/Strategies/IPathFindingStrategy.cs b/src/Lab1/Services/Strategies/IPathFindingStrategy.cs new file mode 100644 index 0000000..5586ac3 --- /dev/null +++ b/src/Lab1/Services/Strategies/IPathFindingStrategy.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Services.Strategies; + +public interface IPathFindingStrategy +{ + PathFinderResult GetBestShip(IEnumerable> results); +} \ No newline at end of file diff --git a/src/Lab1/Ships/ConcreteShips/Avgur.cs b/src/Lab1/Ships/ConcreteShips/Avgur.cs new file mode 100644 index 0000000..0cc617a --- /dev/null +++ b/src/Lab1/Ships/ConcreteShips/Avgur.cs @@ -0,0 +1,30 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; + +public class Avgur : IShip +{ + private readonly IDamagable _hull; + + public Avgur(bool photonDeflector = false, bool antiNitrineEmitter = false) + { + PhotonDeflector = photonDeflector; + AntiNitrineEmitter = antiNitrineEmitter; + DriveEngine = new ExponentialDriveEngine(); + JumpEngine = new AlphaJumpEngine(); + _hull = new DeflectorClass3(new HullClass3()); + } + + public bool PhotonDeflector { get; } + public bool AntiNitrineEmitter { get; } + public IDriveEngine DriveEngine { get; } + public IJumpEngine? JumpEngine { get; } + + public void TakeDamage(double points) + { + _hull.TakeDamage(points); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/ConcreteShips/Meridian.cs b/src/Lab1/Ships/ConcreteShips/Meridian.cs new file mode 100644 index 0000000..6aec0d2 --- /dev/null +++ b/src/Lab1/Ships/ConcreteShips/Meridian.cs @@ -0,0 +1,30 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; + +public class Meridian : IShip +{ + private readonly IDamagable _hull; + + public Meridian(bool photonDeflector = false, bool antiNitrineEmitter = false) + { + PhotonDeflector = photonDeflector; + AntiNitrineEmitter = antiNitrineEmitter; + _hull = new DeflectorClass2(new HullClass2()); + DriveEngine = new ExponentialDriveEngine(); + JumpEngine = null; + } + + public bool PhotonDeflector { get; } + public bool AntiNitrineEmitter { get; } + public IDriveEngine DriveEngine { get; } + public IJumpEngine? JumpEngine { get; } + + public void TakeDamage(double points) + { + _hull.TakeDamage(points); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/ConcreteShips/PleasureShuttle.cs b/src/Lab1/Ships/ConcreteShips/PleasureShuttle.cs new file mode 100644 index 0000000..1b3e9bf --- /dev/null +++ b/src/Lab1/Ships/ConcreteShips/PleasureShuttle.cs @@ -0,0 +1,29 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; + +public class PleasureShuttle : IShip +{ + private readonly IDamagable _hull; + + public PleasureShuttle(bool photonDeflector = false, bool antiNitrineEmitter = false) + { + PhotonDeflector = photonDeflector; + AntiNitrineEmitter = antiNitrineEmitter; + _hull = new HullClass1(); + DriveEngine = new ConstantDriveEngine(); + JumpEngine = null; + } + + public bool PhotonDeflector { get; } + public bool AntiNitrineEmitter { get; } + public IDriveEngine DriveEngine { get; } + public IJumpEngine? JumpEngine { get; } + + public void TakeDamage(double points) + { + _hull.TakeDamage(points); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/ConcreteShips/Stella.cs b/src/Lab1/Ships/ConcreteShips/Stella.cs new file mode 100644 index 0000000..43a0432 --- /dev/null +++ b/src/Lab1/Ships/ConcreteShips/Stella.cs @@ -0,0 +1,30 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; + +public class Stella : IShip +{ + private readonly IDamagable _hull; + + public Stella(bool photonDeflector = false, bool antiNitrineEmitter = false) + { + PhotonDeflector = photonDeflector; + AntiNitrineEmitter = antiNitrineEmitter; + _hull = new DeflectorClass1(new HullClass1()); + DriveEngine = new ConstantDriveEngine(); + JumpEngine = new OmegaJumpEngine(); + } + + public bool PhotonDeflector { get; } + public bool AntiNitrineEmitter { get; } + public IDriveEngine DriveEngine { get; } + public IJumpEngine? JumpEngine { get; } + + public void TakeDamage(double points) + { + _hull.TakeDamage(points); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/ConcreteShips/Vaklass.cs b/src/Lab1/Ships/ConcreteShips/Vaklass.cs new file mode 100644 index 0000000..103f005 --- /dev/null +++ b/src/Lab1/Ships/ConcreteShips/Vaklass.cs @@ -0,0 +1,30 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; + +public class Vaklass : IShip +{ + private readonly IDamagable _hull; + + public Vaklass(bool photonDeflector = false, bool antiNitrineEmitter = false) + { + PhotonDeflector = photonDeflector; + AntiNitrineEmitter = antiNitrineEmitter; + _hull = new DeflectorClass2(new HullClass1()); + DriveEngine = new ExponentialDriveEngine(); + JumpEngine = new GammaJumpEngine(); + } + + public bool PhotonDeflector { get; } + public bool AntiNitrineEmitter { get; } + public IDriveEngine DriveEngine { get; } + public IJumpEngine? JumpEngine { get; } + + public void TakeDamage(double points) + { + _hull.TakeDamage(points); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Deflectors/DeflectorClass1.cs b/src/Lab1/Ships/Deflectors/DeflectorClass1.cs new file mode 100644 index 0000000..68a86af --- /dev/null +++ b/src/Lab1/Ships/Deflectors/DeflectorClass1.cs @@ -0,0 +1,20 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; + +public class DeflectorClass1 : IDamagable +{ + private readonly IDamagable _damagable; + private double _hp = 200; + + public DeflectorClass1(IDamagable damagable) + { + _damagable = damagable; + } + + public double TakeDamage(double points) + { + double diff = _hp - points; + _hp -= points; + + return diff > 0 ? _damagable.TakeDamage(diff) : _damagable.TakeDamage(0); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Deflectors/DeflectorClass2.cs b/src/Lab1/Ships/Deflectors/DeflectorClass2.cs new file mode 100644 index 0000000..34492db --- /dev/null +++ b/src/Lab1/Ships/Deflectors/DeflectorClass2.cs @@ -0,0 +1,20 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; + +public class DeflectorClass2 : IDamagable +{ + private readonly IDamagable _damagable; + private double _hp = 400; + + public DeflectorClass2(IDamagable damagable) + { + _damagable = damagable; + } + + public double TakeDamage(double points) + { + double diff = _hp - points; + _hp -= points; + + return diff > 0 ? _damagable.TakeDamage(diff) : _damagable.TakeDamage(0); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Deflectors/DeflectorClass3.cs b/src/Lab1/Ships/Deflectors/DeflectorClass3.cs new file mode 100644 index 0000000..214febd --- /dev/null +++ b/src/Lab1/Ships/Deflectors/DeflectorClass3.cs @@ -0,0 +1,20 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Deflectors; + +public class DeflectorClass3 : IDamagable +{ + private readonly IDamagable _damagable; + private double _hp = 600; + + public DeflectorClass3(IDamagable damagable) + { + _damagable = damagable; + } + + public double TakeDamage(double points) + { + double diff = _hp - points; + _hp -= points; + + return diff > 0 ? _damagable.TakeDamage(diff) : _damagable.TakeDamage(0); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/DriveEngines/ConstantDriveEngine.cs b/src/Lab1/Ships/Engines/DriveEngines/ConstantDriveEngine.cs new file mode 100644 index 0000000..6973fd8 --- /dev/null +++ b/src/Lab1/Ships/Engines/DriveEngines/ConstantDriveEngine.cs @@ -0,0 +1,9 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; + +public class ConstantDriveEngine : IDriveEngine +{ + public EngineConsumption GetConsumption(int distance) + { + return new EngineConsumption(distance, new Fuel.ActivePlasmaFuel(20)); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/DriveEngines/ExponentialDriveEngine.cs b/src/Lab1/Ships/Engines/DriveEngines/ExponentialDriveEngine.cs new file mode 100644 index 0000000..963a4d6 --- /dev/null +++ b/src/Lab1/Ships/Engines/DriveEngines/ExponentialDriveEngine.cs @@ -0,0 +1,18 @@ +using System; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; + +public class ExponentialDriveEngine : IDriveEngine +{ + private const double TimeFactor = 1.0; + private const double ConsumptionFactor = 1.0; + private const double DistanceFactor = 5.0; + + public EngineConsumption GetConsumption(int distance) + { + int time = (int)(Math.Pow(distance, 2) * TimeFactor); + double consumption = ConsumptionFactor * Math.Exp(DistanceFactor * distance); + + return new EngineConsumption(time, new Fuel.ActivePlasmaFuel(consumption)); + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/DriveEngines/IDriveEngine.cs b/src/Lab1/Ships/Engines/DriveEngines/IDriveEngine.cs new file mode 100644 index 0000000..8eae4c1 --- /dev/null +++ b/src/Lab1/Ships/Engines/DriveEngines/IDriveEngine.cs @@ -0,0 +1,5 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; + +public interface IDriveEngine : IEngine +{ +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/EngineConsumption.cs b/src/Lab1/Ships/Engines/EngineConsumption.cs new file mode 100644 index 0000000..1f4ef99 --- /dev/null +++ b/src/Lab1/Ships/Engines/EngineConsumption.cs @@ -0,0 +1,3 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +public record EngineConsumption(int Time, Fuel Consumption); \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/Fuel.cs b/src/Lab1/Ships/Engines/Fuel.cs new file mode 100644 index 0000000..ce07c79 --- /dev/null +++ b/src/Lab1/Ships/Engines/Fuel.cs @@ -0,0 +1,8 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +public abstract record Fuel(double Amount, double Rarity) +{ + public record ActivePlasmaFuel(double Amount) : Fuel(Amount, 0.5); + + public record GravitonMatterFuel(double Amount) : Fuel(Amount, 1); +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/IEngine.cs b/src/Lab1/Ships/Engines/IEngine.cs new file mode 100644 index 0000000..04bd9bd --- /dev/null +++ b/src/Lab1/Ships/Engines/IEngine.cs @@ -0,0 +1,6 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines; + +public interface IEngine +{ + EngineConsumption GetConsumption(int distance); +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/JumpEngines/AlphaJumpEngine.cs b/src/Lab1/Ships/Engines/JumpEngines/AlphaJumpEngine.cs new file mode 100644 index 0000000..d37cdf0 --- /dev/null +++ b/src/Lab1/Ships/Engines/JumpEngines/AlphaJumpEngine.cs @@ -0,0 +1,14 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; + +public class AlphaJumpEngine : IJumpEngine +{ + public EngineConsumption GetConsumption(int distance) + { + return new EngineConsumption(distance, new Fuel.GravitonMatterFuel(distance)); + } + + public int GetRange() + { + return 80; + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/JumpEngines/GammaJumpEngine.cs b/src/Lab1/Ships/Engines/JumpEngines/GammaJumpEngine.cs new file mode 100644 index 0000000..88cda97 --- /dev/null +++ b/src/Lab1/Ships/Engines/JumpEngines/GammaJumpEngine.cs @@ -0,0 +1,22 @@ +using System; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; + +public class GammaJumpEngine : IJumpEngine +{ + private const double TimeFactor = 1.0; + private const double ConsumptionFactor = 1.0; + + public EngineConsumption GetConsumption(int distance) + { + int time = (int)(Math.Pow(distance, 3) * TimeFactor); + double consumption = Math.Pow(distance, 3) * ConsumptionFactor; + + return new EngineConsumption(time, new Fuel.GravitonMatterFuel(consumption)); + } + + public int GetRange() + { + return 200; + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/JumpEngines/IJumpEngine.cs b/src/Lab1/Ships/Engines/JumpEngines/IJumpEngine.cs new file mode 100644 index 0000000..a863a14 --- /dev/null +++ b/src/Lab1/Ships/Engines/JumpEngines/IJumpEngine.cs @@ -0,0 +1,6 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; + +public interface IJumpEngine : IEngine +{ + int GetRange(); +} \ No newline at end of file diff --git a/src/Lab1/Ships/Engines/JumpEngines/OmegaJumpEngine.cs b/src/Lab1/Ships/Engines/JumpEngines/OmegaJumpEngine.cs new file mode 100644 index 0000000..bd95ee0 --- /dev/null +++ b/src/Lab1/Ships/Engines/JumpEngines/OmegaJumpEngine.cs @@ -0,0 +1,22 @@ +using System; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; + +public class OmegaJumpEngine : IJumpEngine +{ + private const double TimeFactor = 1.0; + private const double ConsumptionFactor = 1.0; + + public EngineConsumption GetConsumption(int distance) + { + int time = (int)(TimeFactor * distance * Math.Log(distance)); + double consumption = ConsumptionFactor * distance * Math.Log(distance); + + return new EngineConsumption(time, new Fuel.GravitonMatterFuel(consumption)); + } + + public int GetRange() + { + return 150; + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Hull/HullClass1.cs b/src/Lab1/Ships/Hull/HullClass1.cs new file mode 100644 index 0000000..d6175c3 --- /dev/null +++ b/src/Lab1/Ships/Hull/HullClass1.cs @@ -0,0 +1,16 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +public class HullClass1 : IDamagable +{ + private double _hp = 200; + + public double TakeDamage(double points) + { + double diff = _hp - points; + _hp -= points; + + if (diff > 0) + return 0; + return diff; + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Hull/HullClass2.cs b/src/Lab1/Ships/Hull/HullClass2.cs new file mode 100644 index 0000000..c1d8655 --- /dev/null +++ b/src/Lab1/Ships/Hull/HullClass2.cs @@ -0,0 +1,16 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +public class HullClass2 : IDamagable +{ + private double _hp = 200; + + public double TakeDamage(double points) + { + double diff = _hp - points; + _hp -= points; + + if (diff > 0) + return 0; + return diff; + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/Hull/HullClass3.cs b/src/Lab1/Ships/Hull/HullClass3.cs new file mode 100644 index 0000000..335ab97 --- /dev/null +++ b/src/Lab1/Ships/Hull/HullClass3.cs @@ -0,0 +1,16 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships.Hull; + +public class HullClass3 : IDamagable +{ + private double _hp = 200; + + public double TakeDamage(double points) + { + double diff = _hp - points; + _hp -= points; + + if (diff > 0) + return 0; + return diff; + } +} \ No newline at end of file diff --git a/src/Lab1/Ships/IDamagable.cs b/src/Lab1/Ships/IDamagable.cs new file mode 100644 index 0000000..1b09607 --- /dev/null +++ b/src/Lab1/Ships/IDamagable.cs @@ -0,0 +1,6 @@ +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships; + +public interface IDamagable +{ + double TakeDamage(double points); +} \ No newline at end of file diff --git a/src/Lab1/Ships/IShip.cs b/src/Lab1/Ships/IShip.cs new file mode 100644 index 0000000..2d5e48a --- /dev/null +++ b/src/Lab1/Ships/IShip.cs @@ -0,0 +1,14 @@ +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.DriveEngines; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.Engines.JumpEngines; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships; + +public interface IShip +{ + bool PhotonDeflector { get; } + bool AntiNitrineEmitter { get; } + + IDriveEngine DriveEngine { get; } + IJumpEngine? JumpEngine { get; } + void TakeDamage(double points); +} \ No newline at end of file diff --git a/src/Lab1/Ships/ShipRepository.cs b/src/Lab1/Ships/ShipRepository.cs new file mode 100644 index 0000000..c5795bd --- /dev/null +++ b/src/Lab1/Ships/ShipRepository.cs @@ -0,0 +1,20 @@ +using System; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Ships; + +public static class ShipRepository +{ + public static IShip CreateShip(string name, bool photonDeflector = false, bool antiNitrineEmitter = false) + { + return name switch + { + "Avgur" => new Avgur(photonDeflector, antiNitrineEmitter), + "PleasureShuttle" => new PleasureShuttle(photonDeflector, antiNitrineEmitter), + "Meridian" => new Meridian(photonDeflector, antiNitrineEmitter), + "Stella" => new Stella(photonDeflector, antiNitrineEmitter), + "Vaklass" => new Vaklass(photonDeflector, antiNitrineEmitter), + _ => throw new ArgumentException($"Unknown ship type: {name}", nameof(name)), + }; + } +} \ No newline at end of file diff --git a/src/Lab2/Lab2.csproj b/src/Lab2/Lab2.csproj index eb46f14..fe308d8 100644 --- a/src/Lab2/Lab2.csproj +++ b/src/Lab2/Lab2.csproj @@ -2,6 +2,7 @@ Itmo.ObjectOrientedProgramming.Lab2 + true diff --git a/src/Lab4/CommandParser/CommandParser.cs b/src/Lab4/CommandParser/CommandParser.cs index 599252f..8dccf55 100644 --- a/src/Lab4/CommandParser/CommandParser.cs +++ b/src/Lab4/CommandParser/CommandParser.cs @@ -3,20 +3,12 @@ using Itmo.ObjectOrientedProgramming.Lab4.CommandParser.ArgumentHandlers.File; using Itmo.ObjectOrientedProgramming.Lab4.CommandParser.ArgumentHandlers.Tree; using Itmo.ObjectOrientedProgramming.Lab4.CommandParser.CommandHandlers; -using Itmo.ObjectOrientedProgramming.Lab4.Commands; namespace Itmo.ObjectOrientedProgramming.Lab4.CommandParser; public class CommandParser { - private readonly ICommandHandler _head; - private readonly FileSystem.FileSystem _fileSystem; - - public CommandParser(FileSystem.FileSystem fileSystem) - { - _fileSystem = fileSystem; - _head = BuildCommandHandlerChain(); - } + private readonly ICommandHandler _head = BuildCommandHandlerChain(); public ParserOutput Parse(string command) { diff --git a/src/Lab4/Lab4.csproj b/src/Lab4/Lab4.csproj index 0710e45..b652258 100644 --- a/src/Lab4/Lab4.csproj +++ b/src/Lab4/Lab4.csproj @@ -2,6 +2,7 @@ Itmo.ObjectOrientedProgramming.Lab4 + true diff --git a/tests/Lab1.Tests/Lab1.Tests.csproj b/tests/Lab1.Tests/Lab1.Tests.csproj index 3b16015..86dd358 100644 --- a/tests/Lab1.Tests/Lab1.Tests.csproj +++ b/tests/Lab1.Tests/Lab1.Tests.csproj @@ -4,6 +4,7 @@ Itmo.ObjectOrientedProgramming.Lab1.Tests false true + true diff --git a/tests/Lab1.Tests/PathFinderTests.cs b/tests/Lab1.Tests/PathFinderTests.cs new file mode 100644 index 0000000..c53b99c --- /dev/null +++ b/tests/Lab1.Tests/PathFinderTests.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using Itmo.ObjectOrientedProgramming.Lab1.Environments; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Services; +using Itmo.ObjectOrientedProgramming.Lab1.Services.Strategies; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; +using Itmo.ObjectOrientedProgramming.Lab1.Ships.ConcreteShips; +using Xunit; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Tests; + +public class PathFinderTests +{ + [Fact] + public void Shuttle_IsPicked_WhenPricesArePriority() + { + // Arrange + var shuttle = new PleasureShuttle(); + var vaklass = new Vaklass(); + + var pathFinder = new PathFinder(new BestPriceStrategy()); + + var route = new Route(new List() + { + new Path(new Cosmos(), 10), + }); + + // Act + PathFinderResult result = pathFinder.SelectShip(route, new List() + { + shuttle, + vaklass, + }); + + // Assert + PathFinderResult.Success success = Assert.IsType(result); + Assert.IsType(success.Ship); + } + + [Fact] + public void Stella_IsPicked_WhenAvgurCantTraverse() + { + // Arrange + var stella = new Stella(); + var avgur = new Avgur(); + + var pathFinder = new PathFinder(new BestPriceStrategy()); + + var route = new Route(new List() + { + new Path(new HighDensity(), 100), + }); + + // Act + PathFinderResult result = pathFinder.SelectShip(route, new List() + { + stella, + avgur, + }); + + // Assert + PathFinderResult.Success success = Assert.IsType(result); + Assert.IsType(success.Ship); + } + + [Fact] + public void Vaklass_IsPicked_InNitrineNebula() + { + // Arrange + var shuttle = new PleasureShuttle(); + var vaklass = new Vaklass(); + + var pathFinder = new PathFinder(new BestPriceStrategy()); + + var route = new Route(new List() + { + new Path(new NitrineNebula(), 100), + }); + + // Act + PathFinderResult result = pathFinder.SelectShip(route, new List() + { + shuttle, + vaklass, + }); + + // Assert + PathFinderResult.Success success = Assert.IsType(result); + Assert.IsType(success.Ship); + } + + [Fact] + public void Avgur_IsPicked_WhenDealingWithObstacles() + { + // Arrange + var shuttle = new PleasureShuttle(); + var vaklass = new Vaklass(); + + var pathFinder = new PathFinder(new BestPriceStrategy()); + + var route = new Route(new List() + { + new(new NitrineNebula(), 10), + }); + + // Act + PathFinderResult result = pathFinder.SelectShip(route, new List() + { + shuttle, + vaklass, + }); + + // Assert + PathFinderResult.Success success = Assert.IsType(result); + Assert.IsType(success.Ship); + } +} \ No newline at end of file diff --git a/tests/Lab1.Tests/ShipsAndRoutesTest.cs b/tests/Lab1.Tests/ShipsAndRoutesTest.cs new file mode 100644 index 0000000..666fb4f --- /dev/null +++ b/tests/Lab1.Tests/ShipsAndRoutesTest.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using Itmo.ObjectOrientedProgramming.Lab1.Environments; +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles; +using Itmo.ObjectOrientedProgramming.Lab1.Obstacles.Interfaces; +using Itmo.ObjectOrientedProgramming.Lab1.Router; +using Itmo.ObjectOrientedProgramming.Lab1.Ships; +using Xunit; + +namespace Itmo.ObjectOrientedProgramming.Lab1.Tests; + +public class ShipsAndRoutesTest +{ + [Theory] + [InlineData("Avgur")] + [InlineData("PleasureShuttle")] + public void Ships_Should_Fail_WhenCantTraverseEnvironment(string name) + { + // Arrange + IShip shuttle = ShipRepository.CreateShip(name); + var path = new Path(new HighDensity(), 100); + + // Act + TraversalResult result = path.TraversePath(shuttle); + + // Assert + Assert.IsType(result); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Ships_Should_Fail_WhenNoFlareProtection(bool antiNitrineEmitter) + { + // Arrange + IShip shuttle = ShipRepository.CreateShip("Vaklass", false, antiNitrineEmitter); + + var obstacles = new List() + { + new AntimatterFlare(), + }; + + var path = new Path(new HighDensity(obstacles), 10); + + // Act + TraversalResult result = path.TraversePath(shuttle); + + // Assert + if (antiNitrineEmitter) + { + Assert.IsType(result); + } + else + { + Assert.IsType(result); + } + } +} \ No newline at end of file diff --git a/tests/Lab2.Tests/Lab2.Tests.csproj b/tests/Lab2.Tests/Lab2.Tests.csproj index f43e640..d1ae3e9 100644 --- a/tests/Lab2.Tests/Lab2.Tests.csproj +++ b/tests/Lab2.Tests/Lab2.Tests.csproj @@ -4,6 +4,7 @@ Itmo.ObjectOrientedProgramming.Lab2.Tests false true + true diff --git a/tests/Lab4.Tests/Lab4.Tests.csproj b/tests/Lab4.Tests/Lab4.Tests.csproj index 9b98c1e..f6d6970 100644 --- a/tests/Lab4.Tests/Lab4.Tests.csproj +++ b/tests/Lab4.Tests/Lab4.Tests.csproj @@ -4,6 +4,7 @@ Itmo.ObjectOrientedProgramming.Lab4.Tests false true + true @@ -12,6 +13,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Lab4.Tests/ParserTests.cs b/tests/Lab4.Tests/ParserTests.cs index 4bb1ec5..0ffe3fd 100644 --- a/tests/Lab4.Tests/ParserTests.cs +++ b/tests/Lab4.Tests/ParserTests.cs @@ -17,7 +17,7 @@ public void Parse_ShouldBeConnect_WhenInputIsConnect() { // Arrange FileSystem.FileSystem? fs = Substitute.For(); - var parser = new CommandParser.CommandParser(fs); + var parser = new CommandParser.CommandParser(); // Act ParserOutput output = parser.Parse("connect /Users/mikedegeofroy/Desktop"); @@ -38,7 +38,7 @@ public void Parse_ShouldBeListDepth3_WhenInputIsListDepth3() // Arrange FileSystem.FileSystem? fs = Substitute.For(); fs.Connect("/Users/mikedegeofroy/Desktop", new MacOsFileSystemStrategy()); - var parser = new CommandParser.CommandParser(fs); + var parser = new CommandParser.CommandParser(); // Act ParserOutput output = parser.Parse("list / -d 3"); @@ -58,7 +58,7 @@ public void Parse_ShouldBeDisconnect_WhenInputIsDisconnect() { // Arrange FileSystem.FileSystem? fs = Substitute.For(); - var parser = new CommandParser.CommandParser(fs); + var parser = new CommandParser.CommandParser(); // Act ParserOutput output = parser.Parse("disconnect"); @@ -79,7 +79,7 @@ public void Parse_ShouldBeTreeGoto_WhenInputIsTreeGoto() // Arrange FileSystem.FileSystem? fs = Substitute.For(); fs.Connect("/Users/mikedegeofroy/Desktop", new MacOsFileSystemStrategy()); - var parser = new CommandParser.CommandParser(fs); + var parser = new CommandParser.CommandParser(); // Act ParserOutput output = parser.Parse("tree goto /itmo"); @@ -100,7 +100,7 @@ public void Parse_ShouldBeFileShow_WhenInputIsFileShowWithPath() // Arrange FileSystem.FileSystem? fs = Substitute.For(); fs.Connect("/Users/mikedegeofroy/Desktop", new MacOsFileSystemStrategy()); - var parser = new CommandParser.CommandParser(fs); + var parser = new CommandParser.CommandParser(); // Act ParserOutput output = parser.Parse("file show /itmo/databases/questions.txt -m console"); @@ -121,7 +121,7 @@ public void Parse_ShouldBeFileMove_WhenInputIsFileMoveWithSourceAndDestination() // Arrange FileSystem.FileSystem? fs = Substitute.For(); fs.Connect("/Users/mikedegeofroy/Desktop", new MacOsFileSystemStrategy()); - var parser = new CommandParser.CommandParser(fs); + var parser = new CommandParser.CommandParser(); // Act ParserOutput output = parser.Parse("file move /itmo/databases/questions.txt /itmo/databases/questions2.txt");