From 2a4a82a5b3dd22be62bc3eed336e6a36e5b61d47 Mon Sep 17 00:00:00 2001 From: Marto Vesheff Date: Mon, 25 Jul 2016 12:08:48 +0300 Subject: [PATCH] Added author's solutions --- .../Dealership-AuthorSolution/Dealership.sln | 22 ++ .../Dealership/Common/Constants.cs | 58 +++ .../Dealership/Common/Enums/Role.cs | 9 + .../Dealership/Common/Enums/VehicleType.cs | 9 + .../Dealership/Common/Validator.cs | 42 ++ .../Dealership/Contracts/ICar.cs | 7 + .../Dealership/Contracts/IComment.cs | 9 + .../Dealership/Contracts/ICommentable.cs | 9 + .../Dealership/Contracts/IMotorcycle.cs | 7 + .../Dealership/Contracts/IPriceable.cs | 7 + .../Dealership/Contracts/ITruck.cs | 7 + .../Dealership/Contracts/IUser.cs | 30 ++ .../Dealership/Contracts/IVehicle.cs | 15 + .../Dealership/Dealership.csproj | 82 ++++ .../Dealership/Engine/Command.cs | 83 ++++ .../Dealership/Engine/DealershipEngine.cs | 363 ++++++++++++++++++ .../Dealership/Engine/ICommand.cs | 11 + .../Dealership/Engine/IEngine.cs | 9 + .../Dealership/Factories/DealershipFactory.cs | 35 ++ .../Factories/IDealershipFactory.cs | 17 + .../Dealership/Models/Car.cs | 40 ++ .../Dealership/Models/Comment.cs | 51 +++ .../Dealership/Models/Motorcycle.cs | 41 ++ .../Dealership/Models/Truck.cs | 42 ++ .../Dealership/Models/User.cs | 161 ++++++++ .../Dealership/Models/Vehicle.cs | 123 ++++++ .../Dealership/Properties/AssemblyInfo.cs | 35 ++ .../Dealership/Startup.cs | 14 + .../App.config | 6 + .../Common/Constants/GlobalConstants.cs | 37 ++ .../Common/Enums/EngineControlUnitType.cs | 10 + .../Common/Enums/ExhaustType.cs | 10 + .../Common/Enums/GenderType.cs | 9 + .../Common/Enums/IntercoolerType.cs | 9 + .../Common/Enums/MotorType.cs | 15 + .../Common/Enums/NumberOfCylindersType.cs | 11 + .../Common/Enums/TireType.cs | 14 + .../Common/Enums/TransmissionType.cs | 10 + .../Common/Enums/TunningPartGradeType.cs | 10 + .../Common/Enums/TurbochargerType.cs | 10 + .../Exceptions/TunningDuplicationException.cs | 32 ++ .../Extensions/IEnumerableExtensions.cs | 15 + .../Common/Utils/DataGenerator.cs | 19 + .../Common/Utils/MetricUnitsConverter.cs | 19 + .../Contracts/IAcceleratable.cs | 10 + .../Contracts/IDriver.cs | 22 ++ .../Contracts/IEngineControlUnit.cs | 9 + .../Contracts/IExhaust.cs | 9 + .../Contracts/IIdentifiable.cs | 7 + .../Contracts/IIntercooler.cs | 9 + .../Contracts/IMotor.cs | 13 + .../Contracts/IMotorVehicle.cs | 43 +++ .../Contracts/IRaceTrack.cs | 26 ++ .../Contracts/ITireSet.cs | 9 + .../Contracts/ITopSpeed.cs | 10 + .../Contracts/ITransmission.cs | 9 + .../Contracts/ITunningPart.cs | 9 + .../Contracts/ITurbocharger.cs | 9 + .../Contracts/IValuable.cs | 7 + .../Contracts/IWeightable.cs | 7 + .../Engine/Engine.cs | 251 ++++++++++++ .../FastAndFurious.ConsoleApplication.csproj | 144 +++++++ .../Models/Common/IdentifiableObject.cs | 23 ++ .../Models/Drivers/Abstract/Driver.cs | 89 +++++ .../Models/Drivers/DominicRendeto.cs | 15 + .../Models/Drivers/Jessi.cs | 15 + .../Models/Drivers/LetiSpaghetti.cs | 15 + .../Models/Drivers/Mia.cs | 15 + .../Models/Drivers/VinBenzin.cs | 14 + .../Models/Drivers/Vince.cs | 15 + .../MotorVehicles/Abstract/MotorVehicle.cs | 119 ++++++ .../Models/MotorVehicles/AcuraIntegraTypeR.cs | 21 + .../Models/MotorVehicles/MitsubishiEclipse.cs | 21 + .../MitsubishiLancerEvolution.cs | 21 + .../Models/MotorVehicles/Nissan350Z.cs | 21 + .../Models/MotorVehicles/NissanGTR.cs | 21 + .../Models/MotorVehicles/NissanSkylineR34.cs | 21 + .../Models/MotorVehicles/SubaruImprezaWRX.cs | 21 + .../Models/Motors/Abstract/Motor.cs | 55 +++ .../Models/Motors/CentaurPulseMotor.cs | 28 ++ .../Models/Motors/HellcatMotor.cs | 28 ++ .../Models/Motors/IronHorseMotor.cs | 28 ++ .../Models/Motors/ShockblazePulsejetMotor.cs | 28 ++ .../Models/Motors/StingrayMotor.cs | 28 ++ .../Models/Motors/TyphoonPulseEngine.cs | 28 ++ .../Models/Tracks/Abstract/RaceTrack.cs | 123 ++++++ .../Models/Tracks/IndianapolisRaceTrack.cs | 26 ++ .../Models/Tracks/MonacoRaceTrack.cs | 26 ++ .../Models/Tracks/StormblazeRaceTrack.cs | 26 ++ .../Tracks/TokioUndergroundRaceTrack.cs | 26 ++ .../Models/Tunnings/Abstract/TunningPart.cs | 65 ++++ .../APREngineControlUnit.cs | 25 ++ .../Abstract/EngineControlUnit.cs | 35 ++ .../DinanEngineControlUnit.cs | 25 ++ .../SCTPerformanceEngineControlUnit.cs | 30 ++ .../ExhaustSystems/Abstract/Exhaust.cs | 36 ++ .../Tunnings/ExhaustSystems/BorlaExhaust.cs | 25 ++ .../ExhaustSystems/MagnaflowExhaust.cs | 25 ++ .../Tunnings/ExhaustSystems/RemusExhaust.cs | 25 ++ .../Intercoolers/Abstract/Intercooler.cs | 36 ++ .../EvolutionXPerformanceIntercooler.cs | 25 ++ .../Intercoolers/ViperGenieIntercooler.cs | 25 ++ .../Models/Tunnings/Tires/Abstract/TireSet.cs | 35 ++ .../Tunnings/Tires/FalkenAzenisTiresSet.cs | 25 ++ .../Tunnings/Tires/MichelinPilotTiresSet.cs | 25 ++ .../Tunnings/Tires/YokohamaAdvanTiresSet.cs | 25 ++ .../Transmissions/Abstract/Transmission.cs | 31 ++ .../Tunnings/Transmissions/BMShortShifter.cs | 25 ++ .../HurstCompetitionManualShifter.cs | 25 ++ .../TWMPerformanceTransmission.cs | 25 ++ .../Turbochargers/Abstract/Turbocharger.cs | 36 ++ .../VortexR35SequentialTurbocharger.cs | 25 ++ .../ZX8ParallelTwinTurbocharger.cs | 25 ++ .../Properties/AssemblyInfo.cs | 36 ++ .../Startup.cs | 11 + .../FastAndFurious.sln | 22 ++ 116 files changed, 3842 insertions(+) create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership.sln create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Constants.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/Role.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/VehicleType.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Validator.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICar.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IComment.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICommentable.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IMotorcycle.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IPriceable.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ITruck.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IUser.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IVehicle.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Dealership.csproj create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/Command.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/DealershipEngine.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/ICommand.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/IEngine.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/DealershipFactory.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/IDealershipFactory.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Car.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Comment.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Motorcycle.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Truck.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/User.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Vehicle.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Properties/AssemblyInfo.cs create mode 100644 Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Startup.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/App.config create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Constants/GlobalConstants.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/EngineControlUnitType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/ExhaustType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/GenderType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/IntercoolerType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/MotorType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/NumberOfCylindersType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TireType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TransmissionType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TunningPartGradeType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TurbochargerType.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Exceptions/TunningDuplicationException.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Extensions/IEnumerableExtensions.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/DataGenerator.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/MetricUnitsConverter.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IAcceleratable.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IDriver.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IEngineControlUnit.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IExhaust.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIdentifiable.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIntercooler.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotorVehicle.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IRaceTrack.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITireSet.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITopSpeed.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITransmission.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITunningPart.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITurbocharger.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IValuable.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IWeightable.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Engine/Engine.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/FastAndFurious.ConsoleApplication.csproj create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Common/IdentifiableObject.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Abstract/Driver.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/DominicRendeto.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Jessi.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/LetiSpaghetti.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Mia.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/VinBenzin.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Vince.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Abstract/MotorVehicle.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/AcuraIntegraTypeR.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiEclipse.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiLancerEvolution.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Nissan350Z.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanGTR.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanSkylineR34.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/SubaruImprezaWRX.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/Abstract/Motor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/CentaurPulseMotor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/HellcatMotor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/IronHorseMotor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/ShockblazePulsejetMotor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/StingrayMotor.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/TyphoonPulseEngine.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/Abstract/RaceTrack.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/IndianapolisRaceTrack.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/MonacoRaceTrack.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/StormblazeRaceTrack.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/TokioUndergroundRaceTrack.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Abstract/TunningPart.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/APREngineControlUnit.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/Abstract/EngineControlUnit.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/DinanEngineControlUnit.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/SCTPerformanceEngineControlUnit.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/Abstract/Exhaust.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/BorlaExhaust.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/MagnaflowExhaust.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/RemusExhaust.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/Abstract/Intercooler.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/EvolutionXPerformanceIntercooler.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/ViperGenieIntercooler.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/Abstract/TireSet.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/FalkenAzenisTiresSet.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/MichelinPilotTiresSet.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/YokohamaAdvanTiresSet.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/Abstract/Transmission.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/BMShortShifter.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/HurstCompetitionManualShifter.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/TWMPerformanceTransmission.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/Abstract/Turbocharger.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/VortexR35SequentialTurbocharger.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/ZX8ParallelTwinTurbocharger.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Properties/AssemblyInfo.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Startup.cs create mode 100644 Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.sln diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership.sln b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership.sln new file mode 100644 index 0000000..12c5aff --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dealership", "Dealership\Dealership.csproj", "{4DB3664E-CDAE-446D-8163-683F6344C24B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DB3664E-CDAE-446D-8163-683F6344C24B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4DB3664E-CDAE-446D-8163-683F6344C24B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4DB3664E-CDAE-446D-8163-683F6344C24B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4DB3664E-CDAE-446D-8163-683F6344C24B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Constants.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Constants.cs new file mode 100644 index 0000000..a238dbb --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Constants.cs @@ -0,0 +1,58 @@ +namespace Dealership.Common +{ + public class Constants + { + // String lengths + public const int MinNameLength = 2; + public const int MaxNameLength = 20; + public const int MinPasswordLength = 5; + public const int MaxPasswordLength = 30; + public const int MinCategoryLength = 3; + public const int MaxCategoryLength = 10; + public const int MinMakeLength = 2; + public const int MaxMakeLength = 15; + public const int MinModelLength = 1; + public const int MaxModelLength = 15; + public const int MinCommentLength = 3; + public const int MaxCommentLength = 200; + + // Numbers validation + public const int MinWheels = 2; + public const int MaxWheels = 10; + public const decimal MinPrice = 0.0m; + public const decimal MaxPrice = 1000000.0m; + public const int MinSeats = 1; + public const int MaxSeats = 10; + public const int MinCapacity = 1; + public const int MaxCapacity = 100; + + // Strings for validation + public const string StringMustBeBetweenMinAndMax = "{0} must be between {1} and {2} characters long!"; + public const string NumberMustBeBetweenMinAndMax = "{0} must be between {1} and {2}!"; + + // Vehicle max to add if not VIP + public const int MaxVehiclesToAdd = 5; + + // Username pattern + public const string UsernamePattern = "^[A-Za-z0-9]+$"; + public const string PasswordPattern = "^[A-Za-z0-9@*_-]+$"; + + // Strings for vehicles, comments and users + public const string InvalidSymbols = "{0} contains invalid symbols!"; + + public const string UserToString = "Username: {0}, FullName: {1} {2}, Role: {3}"; + + public const string CommentCannotBeNull = "Comment cannot be null!"; + public const string VehicleCannotBeNull = "Vehicle cannot be null!"; + + public const string NotAnVipUserVehiclesAdd = "You are not VIP and cannot add more than {0} vehicles!"; + public const string AdminCannotAddVehicles = "You are an admin and therefore cannot add vehicles!"; + + public const string YouAreNotTheAuthor = "You are not the author!"; + public const string UserCannotBeNull = "User cannot be null!"; + + // Added additionally + public const string PropertyCannotBeNull = "{0} cannot be null!"; + + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/Role.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/Role.cs new file mode 100644 index 0000000..b59ab04 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/Role.cs @@ -0,0 +1,9 @@ +namespace Dealership.Common.Enums +{ + public enum Role + { + Normal = 0, + VIP = 1, + Admin = 2 + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/VehicleType.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/VehicleType.cs new file mode 100644 index 0000000..3ee7e61 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Enums/VehicleType.cs @@ -0,0 +1,9 @@ +namespace Dealership.Common.Enums +{ + public enum VehicleType + { + Motorcycle = 2, + Car = 4, + Truck = 8 + } +} \ No newline at end of file diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Validator.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Validator.cs new file mode 100644 index 0000000..2759776 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Common/Validator.cs @@ -0,0 +1,42 @@ +namespace Dealership.Common +{ + using System; + using System.Text.RegularExpressions; + + public static class Validator + { + public static void ValidateIntRange(int value, int min, int max, string message) + { + if (value < min || value > max) + { + throw new ArgumentException(message); + } + } + + public static void ValidateDecimalRange(decimal value, decimal min, decimal max, string message) + { + if (value < min || value > max) + { + throw new ArgumentException(message); + } + } + + public static void ValidateNull(object value, string message) + { + if (value == null) + { + throw new ArgumentNullException(message); + } + } + + public static void ValidateSymbols(string value, string pattern, string message) + { + var regex = new Regex(pattern, RegexOptions.IgnoreCase); + + if (!regex.IsMatch(value)) + { + throw new ArgumentException(message); + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICar.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICar.cs new file mode 100644 index 0000000..6ffde07 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICar.cs @@ -0,0 +1,7 @@ +namespace Dealership.Contracts +{ + public interface ICar + { + int Seats { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IComment.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IComment.cs new file mode 100644 index 0000000..a797287 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IComment.cs @@ -0,0 +1,9 @@ +namespace Dealership.Contracts +{ + public interface IComment + { + string Content { get; } + + string Author { get; set; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICommentable.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICommentable.cs new file mode 100644 index 0000000..ad4efad --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ICommentable.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Dealership.Contracts +{ + public interface ICommentable + { + IList Comments { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IMotorcycle.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IMotorcycle.cs new file mode 100644 index 0000000..18b8f51 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IMotorcycle.cs @@ -0,0 +1,7 @@ +namespace Dealership.Contracts +{ + public interface IMotorcycle + { + string Category { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IPriceable.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IPriceable.cs new file mode 100644 index 0000000..c7cc64b --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IPriceable.cs @@ -0,0 +1,7 @@ +namespace Dealership.Contracts +{ + public interface IPriceable + { + decimal Price { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ITruck.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ITruck.cs new file mode 100644 index 0000000..d3ad82e --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/ITruck.cs @@ -0,0 +1,7 @@ +namespace Dealership.Contracts +{ + public interface ITruck + { + int WeightCapacity { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IUser.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IUser.cs new file mode 100644 index 0000000..6b42ad3 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IUser.cs @@ -0,0 +1,30 @@ +using Dealership.Common.Enums; +using System.Collections.Generic; + +namespace Dealership.Contracts +{ + public interface IUser + { + string Username { get; } + + string FirstName { get; } + + string LastName { get; } + + string Password { get; } + + Role Role { get; } + + IList Vehicles { get; } + + void AddVehicle(IVehicle vehicle); + + void RemoveVehicle(IVehicle vehicle); + + void AddComment(IComment commentToAdd, IVehicle vehicleToAddComment); + + void RemoveComment(IComment commentToRemove, IVehicle vehicleToRemoveComment); + + string PrintVehicles(); + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IVehicle.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IVehicle.cs new file mode 100644 index 0000000..5e3b10a --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Contracts/IVehicle.cs @@ -0,0 +1,15 @@ +namespace Dealership.Contracts +{ + using Dealership.Common.Enums; + + public interface IVehicle : ICommentable, IPriceable + { + int Wheels { get; } + + VehicleType Type { get; } + + string Make { get; } + + string Model { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Dealership.csproj b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Dealership.csproj new file mode 100644 index 0000000..3b13241 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Dealership.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {4DB3664E-CDAE-446D-8163-683F6344C24B} + Exe + Properties + Dealership + Dealership + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/Command.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/Command.cs new file mode 100644 index 0000000..421b91e --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/Command.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Dealership.Engine +{ + public class Command : ICommand + { + private const char SplitCommandSymbol = ' '; + private const string CommentOpenSymbol = "{{"; + private const string CommentCloseSymbol = "}}"; + + private string name; + private List parameters; + + public Command(string input) + { + this.Parameters = new List(); + this.TranslateInput(input); + } + + public string Name + { + get + { + return this.name; + } + + private set + { + if (string.IsNullOrEmpty(value)) + { + + throw new ArgumentNullException("Name cannot be null or empty."); + } + + this.name = value; + } + } + + public List Parameters + { + get + { + return this.parameters; + } + + private set + { + if (value == null) + { + throw new ArgumentNullException("List of strings cannot be null."); + } + + this.parameters = value; + } + } + + private void TranslateInput(string input) + { + var indexOfFirstSeparator = input.IndexOf(SplitCommandSymbol); + var indexOfOpenComment = input.IndexOf(CommentOpenSymbol); + var indexOfCloseComment = input.IndexOf(CommentCloseSymbol); + Regex regex = new Regex("{{.+(?=}})}}"); + + if (indexOfFirstSeparator < 0) + { + this.Name = input; + return; + } + + this.Name = input.Substring(0, indexOfFirstSeparator); + + if (indexOfOpenComment >= 0) + { + this.Parameters.Add(input.Substring(indexOfOpenComment + CommentOpenSymbol.Length, indexOfCloseComment - CommentCloseSymbol.Length - indexOfOpenComment)); + input = regex.Replace(input, string.Empty); + } + + this.Parameters.AddRange(input.Substring(indexOfFirstSeparator + 1).Split(new[] { SplitCommandSymbol }, StringSplitOptions.RemoveEmptyEntries)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/DealershipEngine.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/DealershipEngine.cs new file mode 100644 index 0000000..6a92572 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/DealershipEngine.cs @@ -0,0 +1,363 @@ +using Dealership.Common; +using Dealership.Common.Enums; +using Dealership.Contracts; +using Dealership.Factories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Dealership.Engine +{ + public sealed class DealershipEngine : IEngine + { + // Commands constants + private const string InvalidCommand = "Invalid command!"; + + private const string UserAlreadyExist = "User {0} already exist. Choose a different username!"; + private const string UserLoggedInAlready = "User {0} is logged in! Please log out first!"; + private const string UserRegisterеd = "User {0} registered successfully!"; + private const string UserNotLogged = "You are not logged! Please login first!"; + private const string NoSuchUser = "There is no user with username {0}!"; + private const string UserLoggedOut = "You logged out!"; + private const string UserLoggedIn = "User {0} successfully logged in!"; + private const string WrongUsernameOrPassword = "Wrong username or password!"; + private const string YouAreNotAnAdmin = "You are not an admin!"; + + private const string CommentAddedSuccessfully = "{0} added comment successfully!"; + private const string CommentRemovedSuccessfully = "{0} removed comment successfully!"; + + private const string VehicleRemovedSuccessfully = "{0} removed vehicle successfully!"; + private const string VehicleAddedSuccessfully = "{0} added vehicle successfully!"; + + private const string RemovedVehicleDoesNotExist = "Cannot remove comment! The vehicle does not exist!"; + private const string RemovedCommentDoesNotExist = "Cannot remove comment! The comment does not exist!"; + + private const string CommentDoesNotExist = "The comment does not exist!"; + private const string VehicleDoesNotExist = "The vehicle does not exist!"; + + private static readonly IEngine SingleInstance = new DealershipEngine(); + + private IDealershipFactory factory; + private ICollection users; + private IUser loggedUser; + + private DealershipEngine() + { + this.factory = new DealershipFactory(); + this.users = new List(); + this.loggedUser = null; + } + + public static IEngine Instance + { + get + { + return SingleInstance; + } + } + + public void Start() + { + var commands = this.ReadCommands(); + var commandResult = this.ProcessCommands(commands); + this.PrintReports(commandResult); + } + + public void Reset() + { + this.factory = new DealershipFactory(); + this.users = new List(); + this.loggedUser = null; + var commands = new List(); + var commandResult = new List(); + this.PrintReports(commandResult); + } + + + private IList ReadCommands() + { + var commands = new List(); + + var currentLine = Console.ReadLine(); + + while (!string.IsNullOrEmpty(currentLine)) + { + var currentCommand = new Command(currentLine); + commands.Add(currentCommand); + + currentLine = Console.ReadLine(); + } + + return commands; + } + + private IList ProcessCommands(IList commands) + { + var reports = new List(); + + foreach (var command in commands) + { + try + { + var report = this.ProcessSingleCommand(command); + reports.Add(report); + } + catch (Exception ex) + { + reports.Add(ex.Message); + } + } + + return reports; + } + + private void PrintReports(IList reports) + { + var output = new StringBuilder(); + + foreach (var report in reports) + { + output.AppendLine(report); + output.AppendLine(new string('#', 20)); + } + + Console.Write(output.ToString()); + } + + private string ProcessSingleCommand(ICommand command) + { + if (command.Name != "RegisterUser" && command.Name != "Login") + { + if (this.loggedUser == null) + { + return UserNotLogged; + } + } + + switch (command.Name) + { + case "RegisterUser": + var username = command.Parameters[0]; + var firstName = command.Parameters[1]; + var lastName = command.Parameters[2]; + var password = command.Parameters[3]; + + var role = Role.Normal; + + if (command.Parameters.Count > 4) + { + role = (Role)Enum.Parse(typeof(Role), command.Parameters[4]); + } + + return this.RegisterUser(username, firstName, lastName, password, role); + + case "Login": + username = command.Parameters[0]; + password = command.Parameters[1]; + + return this.Login(username, password); + + case "Logout": + return this.Logout(); + + case "AddVehicle": + var type = command.Parameters[0]; + var make = command.Parameters[1]; + var model = command.Parameters[2]; + var price = decimal.Parse(command.Parameters[3]); + var additionalParam = command.Parameters[4]; + + var typeEnum = (VehicleType)Enum.Parse(typeof(VehicleType), type, true); + + return this.AddVehicle(typeEnum, make, model, price, additionalParam); + + case "RemoveVehicle": + var vehicleIndex = int.Parse(command.Parameters[0]) - 1; + + return this.RemoveVehicle(vehicleIndex); + + case "AddComment": + var content = command.Parameters[0]; + var author = command.Parameters[1]; + vehicleIndex = int.Parse(command.Parameters[2]) - 1; + + return this.AddComment(content, vehicleIndex, author); + + case "RemoveComment": + vehicleIndex = int.Parse(command.Parameters[0]) - 1; + var commentIndex = int.Parse(command.Parameters[1]) - 1; + username = command.Parameters[2]; + + return this.RemoveComment(vehicleIndex, commentIndex, username); + + case "ShowUsers": + + return this.ShowAllUsers(); + + case "ShowVehicles": + username = command.Parameters[0]; + + return this.ShowUserVehicles(username); + + default: + return string.Format(InvalidCommand, command.Name); + } + } + + private string RegisterUser(string username, string firstName, string lastName, string password, Role role) + { + if (this.loggedUser != null) + { + return string.Format(UserLoggedInAlready, this.loggedUser.Username); + } + + if (this.users.Any(u => u.Username.ToLower() == username.ToLower())) + { + return string.Format(UserAlreadyExist, username); + } + + var user = this.factory.CreateUser(username, firstName, lastName, password, role.ToString()); + this.loggedUser = user; + this.users.Add(user); + + return string.Format(UserRegisterеd, username); + } + + private string Login(string username, string password) + { + if (this.loggedUser != null) + { + return string.Format(UserLoggedInAlready, this.loggedUser.Username); + } + + var userFound = this.users.FirstOrDefault(u => u.Username.ToLower() == username.ToLower()); + + if (userFound != null && userFound.Password == password) + { + this.loggedUser = userFound; + return string.Format(UserLoggedIn, username); + } + + return WrongUsernameOrPassword; + } + + private string Logout() + { + this.loggedUser = null; + return UserLoggedOut; + } + + private string AddVehicle(VehicleType type, string make, string model, decimal price, string additionalParam) + { + IVehicle vehicle = null; + + if (type == VehicleType.Car) + { + vehicle = this.factory.CreateCar(make, model, price, int.Parse(additionalParam)); + } + else if (type == VehicleType.Motorcycle) + { + vehicle = this.factory.CreateMotorcycle(make, model, price, additionalParam); + } + else if (type == VehicleType.Truck) + { + vehicle = this.factory.CreateTruck(make, model, price, int.Parse(additionalParam)); + } + + this.loggedUser.AddVehicle(vehicle); + + return string.Format(VehicleAddedSuccessfully, this.loggedUser.Username); + } + + private string RemoveVehicle(int vehicleIndex) + { + ValidateRange(vehicleIndex, 0, this.loggedUser.Vehicles.Count, RemovedVehicleDoesNotExist); + + var vehicle = this.loggedUser.Vehicles[vehicleIndex]; + + this.loggedUser.RemoveVehicle(vehicle); + + return string.Format(VehicleRemovedSuccessfully, this.loggedUser.Username); + } + + private string AddComment(string content, int vehicleIndex, string author) + { + var comment = this.factory.CreateComment(content); + comment.Author = this.loggedUser.Username; + var user = this.users.FirstOrDefault(u => u.Username == author); + + if (user == null) + { + return string.Format(NoSuchUser, author); + } + + ValidateRange(vehicleIndex, 0, user.Vehicles.Count, VehicleDoesNotExist); + + var vehicle = user.Vehicles[vehicleIndex]; + + this.loggedUser.AddComment(comment, vehicle); + + return string.Format(CommentAddedSuccessfully, this.loggedUser.Username); + } + + private string RemoveComment(int vehicleIndex, int commentIndex, string username) + { + var user = this.users.FirstOrDefault(u => u.Username == username); + + if (user == null) + { + return string.Format(NoSuchUser, username); + } + + ValidateRange(vehicleIndex, 0, user.Vehicles.Count, RemovedVehicleDoesNotExist); + ValidateRange(commentIndex, 0, user.Vehicles[vehicleIndex].Comments.Count, RemovedCommentDoesNotExist); + + var vehicle = user.Vehicles[vehicleIndex]; + var comment = user.Vehicles[vehicleIndex].Comments[commentIndex]; + + this.loggedUser.RemoveComment(comment, vehicle); + + return string.Format(CommentRemovedSuccessfully, this.loggedUser.Username); + } + + private string ShowAllUsers() + { + if (this.loggedUser.Role != Role.Admin) + { + return YouAreNotAnAdmin; + } + + var builder = new StringBuilder(); + builder.AppendLine("--USERS--"); + var counter = 1; + foreach (var user in this.users) + { + builder.AppendLine(string.Format("{0}. {1}", counter, user.ToString())); + counter++; + } + + return builder.ToString().Trim(); + } + + private string ShowUserVehicles(string username) + { + var user = this.users.FirstOrDefault(u => u.Username.ToLower() == username.ToLower()); + + if (user == null) + { + return string.Format(NoSuchUser, username); + } + + return user.PrintVehicles(); + } + + private static void ValidateRange(int? value, int min, int max, string message) + { + if (value < min || value >= max) + { + throw new ArgumentException(message); + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/ICommand.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/ICommand.cs new file mode 100644 index 0000000..101c63a --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/ICommand.cs @@ -0,0 +1,11 @@ +namespace Dealership.Engine +{ + using System.Collections.Generic; + + public interface ICommand + { + string Name { get; } + + List Parameters { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/IEngine.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/IEngine.cs new file mode 100644 index 0000000..1e5c118 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Engine/IEngine.cs @@ -0,0 +1,9 @@ +namespace Dealership.Engine +{ + public interface IEngine + { + void Start(); + + void Reset(); + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/DealershipFactory.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/DealershipFactory.cs new file mode 100644 index 0000000..eec74e2 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/DealershipFactory.cs @@ -0,0 +1,35 @@ +using Dealership.Contracts; +using System; +using Dealership.Models; +using Dealership.Common.Enums; + +namespace Dealership.Factories +{ + public class DealershipFactory : IDealershipFactory + { + public IVehicle CreateCar(string make, string model, decimal price, int seats) + { + return new Car(make, model, price, seats); + } + + public IVehicle CreateMotorcycle(string make, string model, decimal price, string category) + { + return new Motorcycle(make, model, price, category); + } + + public IVehicle CreateTruck(string make, string model, decimal price, int weightCapacity) + { + return new Truck(make, model, price, weightCapacity); + } + + public IUser CreateUser(string username, string firstName, string lastName, string password, string role) + { + return new User(username, firstName, lastName, password, (Role)Enum.Parse(typeof(Role), role)); + } + + public IComment CreateComment(string content) + { + return new Comment(content); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/IDealershipFactory.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/IDealershipFactory.cs new file mode 100644 index 0000000..6ce9551 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Factories/IDealershipFactory.cs @@ -0,0 +1,17 @@ +using Dealership.Contracts; + +namespace Dealership.Factories +{ + public interface IDealershipFactory + { + IUser CreateUser(string username, string firstName, string lastName, string password, string role); + + IComment CreateComment(string content); + + IVehicle CreateCar(string make, string model, decimal price, int seats); + + IVehicle CreateMotorcycle(string make, string model, decimal price, string category); + + IVehicle CreateTruck(string make, string model, decimal price, int weightCapacity); + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Car.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Car.cs new file mode 100644 index 0000000..5d3c1d7 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Car.cs @@ -0,0 +1,40 @@ +using Dealership.Common; +using Dealership.Common.Enums; +using Dealership.Contracts; +using System.Text; + +namespace Dealership.Models +{ + public class Car : Vehicle, ICar + { + private const string SeatsProperty = "Seats"; + + private readonly int seats; + + public Car(string make, string model, decimal price, int seats) + : base(make, model, price, VehicleType.Car) + { + this.seats = seats; + + this.ValidateFields(); + } + + public int Seats + { + get + { + return this.seats; + } + } + + protected override string PrintAdditionalInfo() + { + return string.Format(" {0}: {1}", SeatsProperty, this.Seats); + } + + private void ValidateFields() + { + Validator.ValidateIntRange(this.seats, Constants.MinSeats, Constants.MaxSeats, string.Format(Constants.NumberMustBeBetweenMinAndMax, SeatsProperty, Constants.MinSeats, Constants.MaxSeats)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Comment.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Comment.cs new file mode 100644 index 0000000..b9db289 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Comment.cs @@ -0,0 +1,51 @@ +using Dealership.Common; +using Dealership.Contracts; +using System.Text; + +namespace Dealership.Models +{ + public class Comment : IComment + { + private const string CommentHeader = " ----------"; + private const string ContentProperty = "Content"; + private const string CommentIndentation = " "; + private const string AuthorHeader = " User: "; + + private readonly string content; + + public Comment(string content) + { + this.content = content; + + this.ValidateFields(); + } + + public string Content + { + get + { + return this.content; + } + } + + public string Author { get; set; } + + public override string ToString() + { + var builder = new StringBuilder(); + + builder.AppendLine(string.Format("{0}", CommentHeader)); + builder.AppendLine(CommentIndentation + this.Content); + builder.AppendLine(AuthorHeader + this.Author); + builder.Append(string.Format("{0}", CommentHeader)); + + return builder.ToString(); + } + + private void ValidateFields() + { + Validator.ValidateNull(this.content, string.Format(Constants.PropertyCannotBeNull, ContentProperty)); + Validator.ValidateIntRange(this.content.Length, Constants.MinCommentLength, Constants.MaxCommentLength, string.Format(Constants.StringMustBeBetweenMinAndMax, ContentProperty, Constants.MinCommentLength, Constants.MaxCommentLength)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Motorcycle.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Motorcycle.cs new file mode 100644 index 0000000..6614116 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Motorcycle.cs @@ -0,0 +1,41 @@ +using Dealership.Common; +using Dealership.Common.Enums; +using Dealership.Contracts; +using System.Text; + +namespace Dealership.Models +{ + public class Motorcycle : Vehicle, IMotorcycle + { + private const string CategoryProperty = "Category"; + + private readonly string category; + + public Motorcycle(string make, string model, decimal price, string category) + : base(make, model, price, VehicleType.Motorcycle) + { + this.category = category; + + this.ValidateFields(); + } + + public string Category + { + get + { + return this.category; + } + } + + protected override string PrintAdditionalInfo() + { + return string.Format(" {0}: {1}", CategoryProperty, this.Category); + } + + private void ValidateFields() + { + Validator.ValidateNull(this.category, string.Format(Constants.PropertyCannotBeNull, CategoryProperty)); + Validator.ValidateIntRange(this.category.Length, Constants.MinCategoryLength, Constants.MaxCategoryLength, string.Format(Constants.StringMustBeBetweenMinAndMax, CategoryProperty, Constants.MinCategoryLength, Constants.MaxCategoryLength)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Truck.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Truck.cs new file mode 100644 index 0000000..65ec05d --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Truck.cs @@ -0,0 +1,42 @@ +using System.Text; +using Dealership.Common.Enums; +using Dealership.Contracts; +using Dealership.Common; +using System; + +namespace Dealership.Models +{ + public class Truck : Vehicle, ITruck + { + private const string WeightCapacityPropery = "Weight capacity"; + + private readonly int weightCapacity; + + public Truck(string make, string model, decimal price, int weightCapacity) + : base(make, model, price, VehicleType.Truck) + { + this.weightCapacity = weightCapacity; + + this.ValidateFields(); + } + + public int WeightCapacity + { + get + { + return this.weightCapacity; + } + } + + protected override string PrintAdditionalInfo() + { + // Е mnoo sum gaden! Za edna glavna bukva! ЦЦЦЦЦЦЦ :D + return string.Format(" Weight Capacity: {0}t", this.WeightCapacity); + } + + private void ValidateFields() + { + Validator.ValidateIntRange(this.weightCapacity, Constants.MinCapacity, Constants.MaxCapacity, string.Format(Constants.NumberMustBeBetweenMinAndMax, WeightCapacityPropery, Constants.MinCapacity, Constants.MaxCapacity)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/User.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/User.cs new file mode 100644 index 0000000..ba9a91e --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/User.cs @@ -0,0 +1,161 @@ +using Dealership.Contracts; +using System; +using System.Collections.Generic; +using Dealership.Common.Enums; +using Dealership.Common; +using System.Text; + +namespace Dealership.Models +{ + public class User : IUser + { + private const string UsernameProperty = "Username"; + private const string FirstNameProperty = "Firstname"; + private const string LastNameProperty = "Lastname"; + private const string PasswordProperty = "Password"; + private const string NoVehiclesHeader = "--NO VEHICLES--"; + private const string UserHeader = "--USER {0}--"; + + private readonly string firstName; + private readonly string lastName; + private readonly string username; + private readonly string password; + + public User(string username, string firstName, string lastName, string password, Role role) + { + this.username = username; + this.firstName = firstName; + this.lastName = lastName; + this.password = password; + this.Role = role; + this.Vehicles = new List(); + + this.ValidateFields(); + } + + public string Username + { + get + { + return this.username; + } + } + + public string FirstName + { + get + { + return this.firstName; + } + } + + public string LastName + { + get + { + return this.lastName; + } + } + + public string Password + { + get + { + return this.password; + } + } + + public Role Role { get; private set; } + + public IList Vehicles { get; private set; } + + public void AddComment(IComment commentToAdd, IVehicle vehicleToAddComment) + { + Validator.ValidateNull(commentToAdd, Constants.CommentCannotBeNull); + Validator.ValidateNull(vehicleToAddComment, Constants.CommentCannotBeNull); + + vehicleToAddComment.Comments.Add(commentToAdd); + } + + public void AddVehicle(IVehicle vehicle) + { + Validator.ValidateNull(vehicle, Constants.VehicleCannotBeNull); + if (this.Role == Role.Normal && this.Vehicles.Count >= 5) + { + throw new ArgumentException(string.Format(Constants.NotAnVipUserVehiclesAdd, Constants.MaxVehiclesToAdd)); + } + + if (this.Role == Role.Admin) + { + throw new ArgumentException(Constants.AdminCannotAddVehicles); + } + + this.Vehicles.Add(vehicle); + } + + public void RemoveComment(IComment commentToRemove, IVehicle vehicleToRemoveComment) + { + Validator.ValidateNull(vehicleToRemoveComment, Constants.VehicleCannotBeNull); + Validator.ValidateNull(commentToRemove, Constants.CommentCannotBeNull); + + if (this.Username != commentToRemove.Author) + { + throw new ArgumentException(Constants.YouAreNotTheAuthor); + } + + vehicleToRemoveComment.Comments.Remove(commentToRemove); + } + + public void RemoveVehicle(IVehicle vehicle) + { + Validator.ValidateNull(vehicle, Constants.VehicleCannotBeNull); + + this.Vehicles.Remove(vehicle); + } + + public override string ToString() + { + return string.Format(Constants.UserToString, this.Username, this.FirstName, this.LastName, this.Role); + } + + public string PrintVehicles() + { + var builder = new StringBuilder(); + + var counter = 1; + builder.AppendLine(string.Format(UserHeader, this.Username)); + + if (this.Vehicles.Count <= 0) + { + builder.AppendLine(NoVehiclesHeader); + } + else + { + foreach (var vehicle in this.Vehicles) + { + builder.AppendLine(string.Format("{0}. {1}", counter, vehicle.ToString())); + counter++; + } + } + + return builder.ToString().Trim(); + } + + private void ValidateFields() + { + Validator.ValidateNull(this.username, string.Format(Constants.PropertyCannotBeNull, UsernameProperty)); + Validator.ValidateSymbols(this.username, Constants.UsernamePattern, string.Format(Constants.InvalidSymbols, UsernameProperty)); + Validator.ValidateIntRange(this.username.Length, Constants.MinNameLength, Constants.MaxNameLength, string.Format(Constants.StringMustBeBetweenMinAndMax, UsernameProperty, Constants.MinNameLength, Constants.MaxNameLength)); + + Validator.ValidateNull(this.firstName, string.Format(Constants.PropertyCannotBeNull, FirstNameProperty)); + Validator.ValidateIntRange(this.firstName.Length, Constants.MinNameLength, Constants.MaxNameLength, string.Format(Constants.StringMustBeBetweenMinAndMax, FirstNameProperty, Constants.MinNameLength, Constants.MaxNameLength)); + + Validator.ValidateNull(this.lastName, string.Format(Constants.PropertyCannotBeNull, LastNameProperty)); + Validator.ValidateIntRange(this.lastName.Length, Constants.MinNameLength, Constants.MaxNameLength, string.Format(Constants.StringMustBeBetweenMinAndMax, LastNameProperty, Constants.MinNameLength, Constants.MaxNameLength)); + + Validator.ValidateNull(this.password, string.Format(Constants.PropertyCannotBeNull, PasswordProperty)); + Validator.ValidateSymbols(this.password, Constants.PasswordPattern, string.Format(Constants.InvalidSymbols, PasswordProperty)); + Validator.ValidateIntRange(this.password.Length, Constants.MinPasswordLength, Constants.MaxPasswordLength, string.Format(Constants.StringMustBeBetweenMinAndMax, PasswordProperty, Constants.MinPasswordLength, Constants.MaxPasswordLength)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Vehicle.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Vehicle.cs new file mode 100644 index 0000000..4ea1d8e --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Models/Vehicle.cs @@ -0,0 +1,123 @@ +using Dealership.Common; +using Dealership.Common.Enums; +using Dealership.Contracts; +using System.Collections.Generic; +using System.Text; + +namespace Dealership.Models +{ + public abstract class Vehicle : IVehicle, ICommentable + { + private const string MakeProperty = "Make"; + private const string ModelProperty = "Model"; + private const string PriceProperty = "Price"; + private const string WheelsProperty = "Wheels"; + private const string CommentsHeader = " --COMMENTS--"; + private const string NoCommentsHeader = " --NO COMMENTS--"; + + private readonly string make; + private readonly string model; + private readonly decimal price; + private readonly int wheels; + + public Vehicle(string make, string model, decimal price, VehicleType type) + { + this.make = make; + this.model = model; + this.price = price; + this.Type = type; + this.wheels = (int)type; + this.Comments = new List(); + + this.ValidateFields(); + } + + public VehicleType Type { get; protected set; } + + public int Wheels + { + get + { + return this.wheels; + } + } + + public string Make + { + get + { + return this.make; + } + } + + public string Model + { + get + { + return this.model; + } + } + + public IList Comments { get; private set; } + + public decimal Price + { + get + { + return this.price; + } + } + + public override string ToString() + { + var builder = new StringBuilder(); + + builder.AppendLine(string.Format("{0}:", this.GetType().Name)); + builder.AppendLine(string.Format(" {0}: {1}", MakeProperty, this.Make)); + builder.AppendLine(string.Format(" {0}: {1}", ModelProperty, this.Model)); + builder.AppendLine(string.Format(" {0}: {1}", WheelsProperty, this.Wheels)); + builder.AppendLine(string.Format(" {0}: ${1}", PriceProperty, this.Price)); + builder.AppendLine(this.PrintAdditionalInfo()); + builder.AppendLine(this.PrintComments()); + return builder.ToString().TrimEnd(); + } + + protected abstract string PrintAdditionalInfo(); + + private string PrintComments() + { + var builder = new StringBuilder(); + + if (this.Comments.Count <= 0) + { + builder.AppendLine(string.Format("{0}", NoCommentsHeader)); + } + else + { + builder.AppendLine(string.Format("{0}", CommentsHeader)); + + foreach (var comment in this.Comments) + { + builder.AppendLine(comment.ToString()); + } + + builder.AppendLine(string.Format("{0}", CommentsHeader)); + } + + return builder.ToString().TrimEnd(); + } + + private void ValidateFields() + { + Validator.ValidateIntRange(this.wheels, Constants.MinWheels, Constants.MaxWheels, string.Format(Constants.NumberMustBeBetweenMinAndMax, WheelsProperty, Constants.MinWheels, Constants.MaxWheels)); + + Validator.ValidateNull(this.make, string.Format(Constants.PropertyCannotBeNull, MakeProperty)); + Validator.ValidateIntRange(this.make.Length, Constants.MinMakeLength, Constants.MaxMakeLength, string.Format(Constants.StringMustBeBetweenMinAndMax, MakeProperty, Constants.MinMakeLength, Constants.MaxMakeLength)); + + Validator.ValidateNull(this.model, string.Format(Constants.PropertyCannotBeNull, ModelProperty)); + Validator.ValidateIntRange(this.model.Length, Constants.MinModelLength, Constants.MaxModelLength, string.Format(Constants.StringMustBeBetweenMinAndMax, ModelProperty, Constants.MinModelLength, Constants.MaxModelLength)); + + Validator.ValidateDecimalRange(this.price, Constants.MinPrice, Constants.MaxPrice, string.Format(Constants.NumberMustBeBetweenMinAndMax, PriceProperty, Constants.MinPrice, Constants.MaxPrice)); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Properties/AssemblyInfo.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..60e0012 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Dealership")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Dealership")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4db3664e-cdae-446d-8163-683f6344c24b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Startup.cs b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Startup.cs new file mode 100644 index 0000000..c017d61 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/Dealership-AuthorSolution/Dealership/Startup.cs @@ -0,0 +1,14 @@ +using Dealership.Engine; +using System; +using System.IO; + +namespace Dealership +{ + public class Startup + { + public static void Main() + { + DealershipEngine.Instance.Start(); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/App.config b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Constants/GlobalConstants.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Constants/GlobalConstants.cs new file mode 100644 index 0000000..6e92896 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Constants/GlobalConstants.cs @@ -0,0 +1,37 @@ +namespace FastAndFurious.ConsoleApplication.Common.Constants +{ + public class GlobalConstants + { + public const string DriverCannotBeSignedForRaceTrackParticipantMoreThanOnceExceptionMessage = "Cannot sign the same participant to a track"; + public const string DriverCannotBeAssignedAsOwnerToVehicleMoreThanOnceExceptionMessage = "A driver cannot be assigned as owner to a specific vehicle more than once."; + public const string CannotAddMultiplePartsOfTheSameTypeToVehicleExceptionMessage = "Cannot add multiple parts of the same type to a vehicle"; + public const string CannotSetNullObjectAsActiveVehicleExceptionMessage = "Cannot set a null object as an active vehicle."; + public const string CannotSetForeignVehicleAsActiveExceptionMessage = "Cannot set a foreign vehicle as your active vehicle."; + public const string RemovalOperationNotSupportedExceptionMessage = "Removal operation not supported"; + public const string CreationalOperationNotSupportedExceptionMessage = "Creational operation not supported"; + public const string AssigningOperationNotSupportedExceptionMessage = "Assigning operation not supported"; + + public const string CreationStrategyCommand = "-create"; + public const string RemovalStrategyCommand = "-remove"; + public const string AssigningStrategyCommand = "-assign"; + public const string SelectingStrategyCommand = "-select"; + public const string DisplayingStrategyCommand = "-display"; + public const string RunningStrategyCommand = "-run"; + public const string VehicleCommand = "-vehicle"; + public const string DriverCommand = "-driver"; + public const string TunningCommand = "-tunning"; + public const string TrackCommand = "-track"; + public const string ExitCommand = "-exit"; + + public const string PerformingRaceOnTrackMessage = "Performing drag race on track \"{0}\" with {1} participants."; + public const string CannotStartRaceMessage = "Cannot start the race with {0} participants only."; + public const string DisplayBestNTimesEverMessage = "Best {0} times ever for track \"{1}\":"; + public const string DriverSelectsNewVehicleMessage = "{0} now drives {1} {2}"; + public const string ItemAssignedSuccessfullyMessage = "Item with ID:{0} assigned successfully!"; + public const string NoRacesYetMessage = "No races yet for {0}"; + public const string CannotAddMoreParticipantsToRaceTrack = "Cannot add more participants to the Race Track"; + + public const bool ThrowOnError = true; + public const bool IgnoreCase = true; + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/EngineControlUnitType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/EngineControlUnitType.cs new file mode 100644 index 0000000..e6fcc32 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/EngineControlUnitType.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum EngineControlUnitType + { + NotSet = 0, + Stock, + Performance, + Pro + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/ExhaustType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/ExhaustType.cs new file mode 100644 index 0000000..3b76a44 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/ExhaustType.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum ExhaustType + { + NotSet = 0, + NickelChromePlated, + StainlessSteel, + CeramicCoated + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/GenderType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/GenderType.cs new file mode 100644 index 0000000..296868d --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/GenderType.cs @@ -0,0 +1,9 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum GenderType + { + NotSet = 0, + Female, + Male + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/IntercoolerType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/IntercoolerType.cs new file mode 100644 index 0000000..9338e93 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/IntercoolerType.cs @@ -0,0 +1,9 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum IntercoolerType + { + NotSet = 0, + AirToLiquidIntercooler, + ChargeAirIntercooler + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/MotorType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/MotorType.cs new file mode 100644 index 0000000..21a11f2 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/MotorType.cs @@ -0,0 +1,15 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum MotorType + { + NotSet = 0, + ReciprocatingMotor, + TurboPropellerMotor, + SteamMotor, + PulseDetonationMotor, + PulseJet, + RamJet, + ScramJet, + SabreReactionMotor + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/NumberOfCylindersType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/NumberOfCylindersType.cs new file mode 100644 index 0000000..ab98a96 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/NumberOfCylindersType.cs @@ -0,0 +1,11 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum CylinderType + { + NotSet = 0, + V6, + V8, + V12, + V16 + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TireType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TireType.cs new file mode 100644 index 0000000..0ac9444 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TireType.cs @@ -0,0 +1,14 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum TireType + { + NotSet = 0, + AllSeasonTire, + AllTerrainTire, + LowProfileTire, + OffRoadTire, + WinterTire, + MudTire, + PerformanceTire, + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TransmissionType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TransmissionType.cs new file mode 100644 index 0000000..7f89fa0 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TransmissionType.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum TransmissionType + { + NotSet = 0, + ManualShortShifter, + SemiManualShifter, + StockShifter + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TunningPartGradeType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TunningPartGradeType.cs new file mode 100644 index 0000000..62a594e --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TunningPartGradeType.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum TunningGradeType + { + NotSet = 0, + LowGrade, + MidGrade, + HighGrade + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TurbochargerType.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TurbochargerType.cs new file mode 100644 index 0000000..8922e89 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Enums/TurbochargerType.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Common.Enums +{ + public enum TurbochargerType + { + NotSet = 0, + TwinTurbo, + TwinScroll, + SequentialTurbo + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Exceptions/TunningDuplicationException.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Exceptions/TunningDuplicationException.cs new file mode 100644 index 0000000..1bec7b3 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Exceptions/TunningDuplicationException.cs @@ -0,0 +1,32 @@ +using System; +using System.Runtime.Serialization; + +namespace FastAndFurious.ConsoleApplication.Common.Exceptions +{ + public class TunningDuplicationException : ArgumentException + { + public TunningDuplicationException() + { + } + + public TunningDuplicationException(string message) : base(message) + { + } + + public TunningDuplicationException(string message, string paramName) : base(message, paramName) + { + } + + public TunningDuplicationException(string message, Exception innerException) : base(message, innerException) + { + } + + public TunningDuplicationException(string message, string paramName, Exception innerException) : base(message, paramName, innerException) + { + } + + protected TunningDuplicationException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Extensions/IEnumerableExtensions.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Extensions/IEnumerableExtensions.cs new file mode 100644 index 0000000..6b6e2dc --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Extensions/IEnumerableExtensions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FastAndFurious.ConsoleApplication.Contracts; + +namespace FastAndFurious.ConsoleApplication.Common.Extensions +{ + public static class IEnumerableExtensions + { + public static T GetById(this IEnumerable collection, int id) where T : IIdentifiable + { + return collection.FirstOrDefault(x => x.Id == id); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/DataGenerator.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/DataGenerator.cs new file mode 100644 index 0000000..d2b5679 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/DataGenerator.cs @@ -0,0 +1,19 @@ +using System.Threading; + +namespace FastAndFurious.ConsoleApplication.Common.Utils +{ + public static class DataGenerator + { + private static int idCounter; + + static DataGenerator() + { + idCounter = 0; + } + + public static int GenerateId() + { + return Interlocked.Increment(ref idCounter); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/MetricUnitsConverter.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/MetricUnitsConverter.cs new file mode 100644 index 0000000..86dedc3 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Common/Utils/MetricUnitsConverter.cs @@ -0,0 +1,19 @@ +using System; + +namespace FastAndFurious.ConsoleApplication.Common.Utils +{ + public static class MetricUnitsConverter + { + private const int MinutesInHour = 60; + private const int SecondsInMinute = 60; + private const decimal MetersInAKilometer = 1000m; + + public static int GetMetersPerSecondFrom(int kilometersPerHour) + { + var expression = (kilometersPerHour * MetersInAKilometer) / (MinutesInHour * SecondsInMinute); + var metersPerSecond = Convert.ToInt32(Math.Ceiling(expression)); + + return metersPerSecond; + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IAcceleratable.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IAcceleratable.cs new file mode 100644 index 0000000..725e8a4 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IAcceleratable.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IAccelerateable + { + /// + /// Defines the acceleration provided in meters per second squared (m/s^2) + /// + int Acceleration { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IDriver.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IDriver.cs new file mode 100644 index 0000000..b282d83 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IDriver.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IDriver : IIdentifiable + { + string Name { get; } + + GenderType Gender { get; } + + IMotorVehicle ActiveVehicle { get; } + + IEnumerable Vehicles { get; } + + void AddVehicle(IMotorVehicle vehicle); + + void SetActiveVehicle(IMotorVehicle vehicle); + + bool RemoveVehicle(IMotorVehicle vehicle); + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IEngineControlUnit.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IEngineControlUnit.cs new file mode 100644 index 0000000..b622608 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IEngineControlUnit.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IEngineControlUnit : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + EngineControlUnitType EngineControlUnitType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IExhaust.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IExhaust.cs new file mode 100644 index 0000000..ccefa91 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IExhaust.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IExhaust : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + ExhaustType ExhaustType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIdentifiable.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIdentifiable.cs new file mode 100644 index 0000000..3a5511b --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIdentifiable.cs @@ -0,0 +1,7 @@ +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IIdentifiable + { + int Id { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIntercooler.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIntercooler.cs new file mode 100644 index 0000000..37e5d55 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IIntercooler.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IIntercooler : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + IntercoolerType IntercoolerType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotor.cs new file mode 100644 index 0000000..611cc68 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotor.cs @@ -0,0 +1,13 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IMotor : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + int Horsepower { get; } + + MotorType EngineType { get; } + + CylinderType CylinderType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotorVehicle.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotorVehicle.cs new file mode 100644 index 0000000..fcd7190 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IMotorVehicle.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IMotorVehicle : IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + /// + /// Collects all of the tunning parts applied to the vehicle. + /// (Intercoolers, Turbochargers, Exhaust systems, Transmissions, Tires, Engine control units, etc...) + /// + IEnumerable TunningParts { get; } + + /// + /// Calculates the time required to finish a race given the track length in meters. + /// Returns the time required to finish a race. + /// + /// + /// The track length in meters. + /// + /// + /// Returns the time required to finish a race. + /// + TimeSpan Race(int trackLengthInMeters); + + /// + /// Applies tunning parts to the vehicle. + /// + /// + /// The tunning part to be applied. + /// + void AddTunning(ITunningPart part); + + /// + /// Removes the specified tunning part from the vehicle's systems. + /// + /// + /// Returns "true" if the part was successfully removed. + /// Or "false" if the removal failed. + /// + bool RemoveTunning(ITunningPart part); + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IRaceTrack.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IRaceTrack.cs new file mode 100644 index 0000000..cc3e8b7 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IRaceTrack.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IRaceTrack : IIdentifiable + { + int TrackLengthInMeters { get; } + + int MaxParticipantsCount { get; } + + int MinParticipantsCount { get; } + + string TrackName { get; } + + IEnumerable Participants { get; } + + IEnumerable> FinishedRacesResults { get; } + + void AddParticipant(IDriver participant); + + bool RemoveParticipant(IDriver participant); + + void RunRace(); + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITireSet.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITireSet.cs new file mode 100644 index 0000000..5d59750 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITireSet.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface ITireSet : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + TireType TireType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITopSpeed.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITopSpeed.cs new file mode 100644 index 0000000..8509e71 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITopSpeed.cs @@ -0,0 +1,10 @@ +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface ITopSpeed + { + /// + /// Defines the top speed provided in kilometers per hour (km/h). + /// + int TopSpeed { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITransmission.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITransmission.cs new file mode 100644 index 0000000..d5f366d --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITransmission.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface ITransmission : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + TransmissionType TransmissionType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITunningPart.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITunningPart.cs new file mode 100644 index 0000000..027ea64 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITunningPart.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface ITunningPart : IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + TunningGradeType GradeType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITurbocharger.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITurbocharger.cs new file mode 100644 index 0000000..bab6dca --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/ITurbocharger.cs @@ -0,0 +1,9 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; + +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface ITurbocharger : ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + TurbochargerType TurbochargerType { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IValuable.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IValuable.cs new file mode 100644 index 0000000..6872d00 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IValuable.cs @@ -0,0 +1,7 @@ +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IValuable + { + decimal Price { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IWeightable.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IWeightable.cs new file mode 100644 index 0000000..4e810eb --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Contracts/IWeightable.cs @@ -0,0 +1,7 @@ +namespace FastAndFurious.ConsoleApplication.Contracts +{ + public interface IWeightable + { + int Weight { get; } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Engine/Engine.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Engine/Engine.cs new file mode 100644 index 0000000..c55ad3d --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Engine/Engine.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using FastAndFurious.ConsoleApplication.Common.Constants; +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Common.Exceptions; +using FastAndFurious.ConsoleApplication.Common.Extensions; +using FastAndFurious.ConsoleApplication.Contracts; + +namespace FastAndFurious.ConsoleApplication.Engine +{ + public class Engine + { + private readonly ICollection drivers; + private readonly ICollection raceTracks; + private readonly ICollection tunningParts; + private readonly ICollection motorVehicles; + + public Engine() + { + this.drivers = new List(); + this.raceTracks = new List(); + this.tunningParts = new List(); + this.motorVehicles = new List(); + } + + public void Start() + { + var command = ReadCommand(); + var commandParameters = new string[] { string.Empty }; + + while (command != GlobalConstants.ExitCommand) + { + commandParameters = ParseCommand(command); + try + { + ExecuteCommand(commandParameters); + } + catch (NotSupportedException e) + { + Console.Write(e.Message); + } + catch (InvalidOperationException e) + { + Console.WriteLine(e.Message); + } + catch (TunningDuplicationException e) + { + Console.WriteLine(e.Message); + } + command = ReadCommand(); + } + } + + public string ReadCommand() + { + return Console.ReadLine(); + } + + public string[] ParseCommand(string command) + { + return command.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); + } + + public void ExecuteCommand(string[] commandParameters) + { + // Choose strategy + var commandType = commandParameters[0]; + switch (commandType) + { + case GlobalConstants.CreationStrategyCommand: + this.ExecuteCreationStrategy(commandParameters); + break; + case GlobalConstants.RemovalStrategyCommand: + this.ExecuteRemovalStrategy(commandParameters); + break; + case GlobalConstants.AssigningStrategyCommand: + this.ExecuteAssigningStrategy(commandParameters); + break; + case GlobalConstants.SelectingStrategyCommand: + this.ExecuteSelectingStrategy(commandParameters); + break; + case GlobalConstants.RunningStrategyCommand: + this.ExecuteRunningStrategy(commandParameters); + break; + case GlobalConstants.DisplayingStrategyCommand: + this.ExecuteDisplayingStrategy(commandParameters); + break; + default: + throw new InvalidOperationException(); + } + } + + public void ExecuteCreationStrategy(string[] commandParameters) + { + var createTypeCommand = commandParameters[1]; + var typeName = commandParameters[2]; + + switch (createTypeCommand) + { + case GlobalConstants.DriverCommand: + this.CreateObjectOfTypeAndAssignToCollection(typeName, this.drivers); + break; + case GlobalConstants.TrackCommand: + this.CreateObjectOfTypeAndAssignToCollection(typeName, this.raceTracks); + break; + case GlobalConstants.TunningCommand: + this.CreateObjectOfTypeAndAssignToCollection(typeName, this.tunningParts); + break; + case GlobalConstants.VehicleCommand: + this.CreateObjectOfTypeAndAssignToCollection(typeName, this.motorVehicles); + break; + default: + throw new NotSupportedException(GlobalConstants.CreationalOperationNotSupportedExceptionMessage); + } + + Console.WriteLine(String.Format("{0} - successfully created!", typeName)); + } + + public void ExecuteAssigningStrategy(string[] commandParameters) + { + var removeTypeCommand = commandParameters[1]; + var objectToAssignId = int.Parse(commandParameters[2]); + var ownerToAssignToId = int.Parse(commandParameters[5]); + + switch (removeTypeCommand) + { + case GlobalConstants.TunningCommand: + { + var vehicleToAssignTo = this.motorVehicles.GetById(ownerToAssignToId); + var tunningToAssign = this.tunningParts.GetById(objectToAssignId); + vehicleToAssignTo.AddTunning(tunningToAssign); + break; + } + case GlobalConstants.VehicleCommand: + { + var driverToAssignTo = this.drivers.GetById(ownerToAssignToId); + var vehicleToAssign = this.motorVehicles.GetById(objectToAssignId); + driverToAssignTo.AddVehicle(vehicleToAssign); + break; + } + case GlobalConstants.DriverCommand: + { + var raceTrackToAssignTo = this.raceTracks.GetById(ownerToAssignToId); + var driverToAssign = this.drivers.GetById(objectToAssignId); + raceTrackToAssignTo.AddParticipant(driverToAssign); + break; + } + default: + { + throw new NotSupportedException(GlobalConstants.AssigningOperationNotSupportedExceptionMessage); + } + } + + Console.WriteLine( + String.Format( + GlobalConstants.ItemAssignedSuccessfullyMessage, + objectToAssignId, + ownerToAssignToId)); + } + + public void ExecuteRemovalStrategy(string[] commandParameters) + { + var removeTypeCommand = commandParameters[1]; + var objectToRemoveId = int.Parse(commandParameters[2]); + var ownerToRemoveFromId = int.Parse(commandParameters[5]); + + switch (removeTypeCommand) + { + case GlobalConstants.DriverCommand: + { + var raceTrackToRemoveFrom = this.raceTracks.GetById(ownerToRemoveFromId); + var driverToRemove = raceTrackToRemoveFrom.Participants.GetById(objectToRemoveId); + raceTrackToRemoveFrom.RemoveParticipant(driverToRemove); + break; + } + case GlobalConstants.TunningCommand: + { + var vehicleToRemoveFrom = this.motorVehicles.GetById(ownerToRemoveFromId); + var tunningPartToRemove = vehicleToRemoveFrom.TunningParts.GetById(objectToRemoveId); + vehicleToRemoveFrom.RemoveTunning(tunningPartToRemove); + break; + } + case GlobalConstants.VehicleCommand: + { + var driverToRemoveFrom = this.drivers.GetById(ownerToRemoveFromId); + var vehicleToRemove = driverToRemoveFrom.Vehicles.GetById(objectToRemoveId); + driverToRemoveFrom.RemoveVehicle(vehicleToRemove); + break; + } + default: + { + throw new NotSupportedException(GlobalConstants.RemovalOperationNotSupportedExceptionMessage); + } + } + } + + public void ExecuteSelectingStrategy(string[] commandParameters) + { + var driverId = int.Parse(commandParameters[5]); + var driver = this.drivers.GetById(driverId); + var vehicleId = int.Parse(commandParameters[2]); + var vehicle = driver.Vehicles.GetById(vehicleId); + driver.SetActiveVehicle(vehicle); + + Console.WriteLine( + String.Format( + GlobalConstants.DriverSelectsNewVehicleMessage, + driver.Name, + driver.Gender == GenderType.Male ? "his" : "her", + vehicle.GetType().Name)); + } + + public void ExecuteRunningStrategy(string[] commandParameters) + { + var trackId = int.Parse(commandParameters[2]); + var track = this.raceTracks.GetById(trackId); + Console.WriteLine(String.Format(GlobalConstants.PerformingRaceOnTrackMessage, track.TrackName, track.Participants.Count())); + track.RunRace(); + } + + public void ExecuteDisplayingStrategy(string[] commandParameters) + { + var count = int.Parse(commandParameters[2]); + var raceTrackId = int.Parse(commandParameters[6]); + var raceTrack = this.raceTracks.GetById(raceTrackId); + var results = raceTrack.FinishedRacesResults + .SelectMany(x => x) + .OrderBy(x => x.TotalSeconds) + .Take(count); + + Console.WriteLine( + results != null && results.Count() > 0 ? + String.Format(GlobalConstants.DisplayBestNTimesEverMessage, count, raceTrack.TrackName) : + String.Format(GlobalConstants.NoRacesYetMessage, raceTrack.TrackName)); + + foreach (var result in results) + { + Console.WriteLine(result.ToString()); + } + } + + public void CreateObjectOfTypeAndAssignToCollection(string typeName, ICollection collection) + { + var typeToInstantiate = Assembly.GetCallingAssembly().GetTypes().FirstOrDefault(x => x.Name == typeName); + var instanceOfType = (T)Activator.CreateInstance(typeToInstantiate); + collection.Add(instanceOfType); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/FastAndFurious.ConsoleApplication.csproj b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/FastAndFurious.ConsoleApplication.csproj new file mode 100644 index 0000000..635c182 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/FastAndFurious.ConsoleApplication.csproj @@ -0,0 +1,144 @@ + + + + + Debug + AnyCPU + {B77BABFA-3BA7-4FC2-9955-63572D999DC7} + Exe + Properties + FastAndFurious.ConsoleApplication + FastAndFurious.ConsoleApplication + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Common/IdentifiableObject.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Common/IdentifiableObject.cs new file mode 100644 index 0000000..cd7b5f9 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Common/IdentifiableObject.cs @@ -0,0 +1,23 @@ +using FastAndFurious.ConsoleApplication.Common.Utils; +using FastAndFurious.ConsoleApplication.Contracts; + +namespace FastAndFurious.ConsoleApplication.Models.Common +{ + public class IdentifiableObject : IIdentifiable + { + private readonly int id; + + public IdentifiableObject() + { + this.id = DataGenerator.GenerateId(); + } + + public int Id + { + get + { + return this.id; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Abstract/Driver.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Abstract/Driver.cs new file mode 100644 index 0000000..3644c49 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Abstract/Driver.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FastAndFurious.ConsoleApplication.Common.Constants; +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Common; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers.Abstract +{ + public abstract class Driver : IdentifiableObject, IDriver + { + private readonly string name; + private readonly GenderType gender; + private readonly ICollection vehicles; + private IMotorVehicle activeVehicle; + + public Driver(string name, GenderType gender) : base() + { + this.name = name; + this.gender = gender; + this.vehicles = new List(); + } + + public IEnumerable Vehicles + { + get + { + return this.vehicles; + } + } + + public string Name + { + get + { + return this.name; + } + } + + public IMotorVehicle ActiveVehicle + { + get + { + return this.activeVehicle; + } + } + + public GenderType Gender + { + get + { + return this.gender; + } + } + + public void AddVehicle(IMotorVehicle vehicle) + { + if (this.Vehicles.Any(x => x.Id == vehicle.Id)) + { + throw new ArgumentException(GlobalConstants.DriverCannotBeAssignedAsOwnerToVehicleMoreThanOnceExceptionMessage); + } + + this.vehicles.Add(vehicle); + } + + public bool RemoveVehicle(IMotorVehicle vehicle) + { + return this.vehicles.Remove(vehicle); + } + + public void SetActiveVehicle(IMotorVehicle vehicle) + { + // TODO: STDIMPL + + if (vehicle == null) + { + throw new ArgumentNullException(GlobalConstants.CannotSetNullObjectAsActiveVehicleExceptionMessage); + } + + if (!this.Vehicles.Any(x => x.Id == vehicle.Id)) + { + throw new InvalidOperationException(GlobalConstants.CannotSetForeignVehicleAsActiveExceptionMessage); + } + + this.activeVehicle = vehicle; + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/DominicRendeto.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/DominicRendeto.cs new file mode 100644 index 0000000..cbffd37 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/DominicRendeto.cs @@ -0,0 +1,15 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Models.Drivers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers +{ + public class DominicRendeto : Driver + { + private const string DominicRendetoDriverName = "Dominic Rendeto"; + + public DominicRendeto() + : base(DominicRendetoDriverName, GenderType.Male) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Jessi.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Jessi.cs new file mode 100644 index 0000000..5182619 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Jessi.cs @@ -0,0 +1,15 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Models.Drivers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers +{ + public class Jessi : Driver + { + private const string JessiDriverName = "Jessi"; + + public Jessi() + : base(JessiDriverName, GenderType.Female) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/LetiSpaghetti.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/LetiSpaghetti.cs new file mode 100644 index 0000000..0b995ad --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/LetiSpaghetti.cs @@ -0,0 +1,15 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Models.Drivers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers +{ + public class LetiSpaghetti : Driver + { + public const string LetiSpaghettiDriverName = "Leti Spaghetti"; + + public LetiSpaghetti() + : base(LetiSpaghettiDriverName, GenderType.Female) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Mia.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Mia.cs new file mode 100644 index 0000000..7fda16c --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Mia.cs @@ -0,0 +1,15 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Models.Drivers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers +{ + public class Mia : Driver + { + private const string MiaRendetoDriverName = "Mia"; + + public Mia() + : base(MiaRendetoDriverName, GenderType.Female) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/VinBenzin.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/VinBenzin.cs new file mode 100644 index 0000000..a088d56 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/VinBenzin.cs @@ -0,0 +1,14 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Models.Drivers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers +{ + public class VinBenzin : Driver + { + public const string VinBenzinDriverName = "Vin Benzin"; + + public VinBenzin() : base(VinBenzinDriverName, GenderType.Male) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Vince.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Vince.cs new file mode 100644 index 0000000..6ee54a1 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Drivers/Vince.cs @@ -0,0 +1,15 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Models.Drivers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Drivers +{ + public class Vince : Driver + { + public const string VinceDriverName = "Vince"; + + public Vince() + : base(VinceDriverName, GenderType.Male) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Abstract/MotorVehicle.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Abstract/MotorVehicle.cs new file mode 100644 index 0000000..0a74734 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Abstract/MotorVehicle.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FastAndFurious.ConsoleApplication.Common.Constants; +using FastAndFurious.ConsoleApplication.Common.Exceptions; +using FastAndFurious.ConsoleApplication.Common.Utils; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Common; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract +{ + public abstract class MotorVehicle : IdentifiableObject, IMotorVehicle, IWeightable, IValuable, IIdentifiable + { + private readonly int weight; + private readonly int topSpeed; + private readonly int acceleration; + private readonly decimal price; + private readonly ICollection tunningParts; + + public MotorVehicle( + decimal price, + int weight, + int topSpeed, + int acceleration) + : base() + { + this.price = price; + this.weight = weight; + this.acceleration = acceleration; + this.topSpeed = topSpeed; + this.tunningParts = new List(); + } + + public decimal Price + { + get + { + return this.Price + this.TunningParts.Sum(x => x.Price); + } + } + + public int Weight + { + get + { + return this.weight + this.TunningParts.Sum(x => x.Weight); + } + } + + public int Acceleration + { + get + { + return this.acceleration + this.TunningParts.Sum(x => x.Acceleration); + } + } + + public int TopSpeed + { + get + { + return this.topSpeed + this.TunningParts.Sum(x => x.TopSpeed); + } + } + + public IEnumerable TunningParts + { + get + { + return this.tunningParts; + } + } + + public void AddTunning(ITunningPart part) + { + if (this.TunningParts.Any(x => x.GetType().BaseType == part.GetType().BaseType)) + { + var message = GlobalConstants.CannotAddMultiplePartsOfTheSameTypeToVehicleExceptionMessage; + var parameter = part.GetType().Name; + throw new TunningDuplicationException(message, parameter); + } + + this.tunningParts.Add(part); + } + + public bool RemoveTunning(ITunningPart part) + { + return this.tunningParts.Remove(part); + } + + public TimeSpan Race(int trackLengthInMeters) + { + var topSpeedInMetersPerSecond = MetricUnitsConverter.GetMetersPerSecondFrom(this.TopSpeed); + var accelerationInMetersPerSecondSquared = this.Acceleration; + + var timeRequiredToReachTopSpeedInSeconds = (topSpeedInMetersPerSecond / accelerationInMetersPerSecondSquared); + var distanceTravelledWhileReachingTopSpeedInMeters = accelerationInMetersPerSecondSquared * Math.Pow(timeRequiredToReachTopSpeedInSeconds, 2); + + if (trackLengthInMeters == distanceTravelledWhileReachingTopSpeedInMeters) + { + return TimeSpan.FromSeconds(timeRequiredToReachTopSpeedInSeconds); + } + else if (trackLengthInMeters > distanceTravelledWhileReachingTopSpeedInMeters) + { + var remainingDistanceInMeters = trackLengthInMeters - distanceTravelledWhileReachingTopSpeedInMeters; + var timeRequiredToTravelRemainingDistanceInSeconds = remainingDistanceInMeters / topSpeedInMetersPerSecond; + var totalTimeInSeconds = timeRequiredToReachTopSpeedInSeconds + timeRequiredToTravelRemainingDistanceInSeconds; + + return TimeSpan.FromSeconds(totalTimeInSeconds); + } + else + { + var totalTime = Math.Sqrt((trackLengthInMeters / accelerationInMetersPerSecondSquared)); + + return TimeSpan.FromSeconds(totalTime); + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/AcuraIntegraTypeR.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/AcuraIntegraTypeR.cs new file mode 100644 index 0000000..15a41bc --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/AcuraIntegraTypeR.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class AcuraIntegraTypeR : MotorVehicle + { + private const int AcuraIntegraTypeRWeightInGrams = 1700000; + private const int AcuraIntegraTypeRAcceleration = 15; + private const int AcuraIntegraTypeRTopSpeed = 200; + private const decimal AcuraIntegraTypeRPriceInUSADollars = 24999; + + public AcuraIntegraTypeR() + : base( + AcuraIntegraTypeRPriceInUSADollars, + AcuraIntegraTypeRWeightInGrams, + AcuraIntegraTypeRTopSpeed, + AcuraIntegraTypeRAcceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiEclipse.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiEclipse.cs new file mode 100644 index 0000000..4c50764 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiEclipse.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class MitsubishiEclipse : MotorVehicle + { + private const int MitsubishiEclipseWeightInGrams = 1400000; + private const int MitsubishiEclipseAcceleration = 24; + private const int MitsubishiEclipseTopSpeed = 230; + private const decimal MitsubishiEclipsePriceInUSADollars = 29999; + + public MitsubishiEclipse() + : base( + MitsubishiEclipsePriceInUSADollars, + MitsubishiEclipseWeightInGrams, + MitsubishiEclipseTopSpeed, + MitsubishiEclipseAcceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiLancerEvolution.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiLancerEvolution.cs new file mode 100644 index 0000000..8c68c83 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/MitsubishiLancerEvolution.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class MitsubishiLancerEvolution : MotorVehicle + { + private const int MitsubishiLancerEvolutionWeightInGrams = 1780000; + private const int MitsubishiLancerEvolutionAcceleration = 20; + private const int MitsubishiLancerEvolutionTopSpeed = 300; + private const decimal MitsubishiLancerEvolutionPriceInUSADollars = 56999; + + public MitsubishiLancerEvolution() + : base( + MitsubishiLancerEvolutionPriceInUSADollars, + MitsubishiLancerEvolutionWeightInGrams, + MitsubishiLancerEvolutionTopSpeed, + MitsubishiLancerEvolutionAcceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Nissan350Z.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Nissan350Z.cs new file mode 100644 index 0000000..224d032 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/Nissan350Z.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class Nissan350Z : MotorVehicle + { + private const int Nissan350ZWeightInGrams = 1280000; + private const int Nissan350ZAcceleration = 55; + private const int Nissan350ZTopSpeed = 220; + private const decimal Nissan350ZPriceInUSADollars = 25999; + + public Nissan350Z() + : base( + Nissan350ZPriceInUSADollars, + Nissan350ZWeightInGrams, + Nissan350ZTopSpeed, + Nissan350ZAcceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanGTR.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanGTR.cs new file mode 100644 index 0000000..44dcf73 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanGTR.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class NissanGTR : MotorVehicle + { + private const int NissanGTRWeightInGrams = 1850000; + private const int NissanGTRAcceleration = 45; + private const int NissanGTRTopSpeed = 300; + private const decimal NissanGTRPriceInUSADollars = 125000; + + public NissanGTR() + : base( + NissanGTRPriceInUSADollars, + NissanGTRWeightInGrams, + NissanGTRTopSpeed, + NissanGTRAcceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanSkylineR34.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanSkylineR34.cs new file mode 100644 index 0000000..a3cde0f --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/NissanSkylineR34.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class NissanSkylineR34 : MotorVehicle + { + private const int NissanSkylineR34WeightInGrams = 1850000; + private const int NissanSkylineR34Acceleration = 50; + private const int NissanSkylineR34TopSpeed = 280; + private const decimal NissanSkylineR34PriceInUSADollars = 45999; + + public NissanSkylineR34() + : base( + NissanSkylineR34PriceInUSADollars, + NissanSkylineR34WeightInGrams, + NissanSkylineR34TopSpeed, + NissanSkylineR34Acceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/SubaruImprezaWRX.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/SubaruImprezaWRX.cs new file mode 100644 index 0000000..6b992ba --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/MotorVehicles/SubaruImprezaWRX.cs @@ -0,0 +1,21 @@ +using FastAndFurious.ConsoleApplication.Models.MotorVehicles.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.MotorVehicles +{ + public class SubaruImprezaWRX : MotorVehicle + { + private const int SubaruImprezaWRXWeightInGrams = 1560000; + private const int SubaruImprezaWRXAcceleration = 35; + private const int SubaruImprezaWRXTopSpeed = 260; + private const decimal SubaruImprezaWRXPriceInUSADollars = 55999; + + public SubaruImprezaWRX() + : base( + SubaruImprezaWRXPriceInUSADollars, + SubaruImprezaWRXWeightInGrams, + SubaruImprezaWRXTopSpeed, + SubaruImprezaWRXAcceleration) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/Abstract/Motor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/Abstract/Motor.cs new file mode 100644 index 0000000..cb051f0 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/Abstract/Motor.cs @@ -0,0 +1,55 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors.Abstract +{ + public abstract class Motor : TunningPart, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly int horsepower; + private readonly MotorType engineType; + private readonly CylinderType cylinderType; + + public Motor( + decimal price, + int weight, + int acceleration, + int topSpeed, + int horsepower, + TunningGradeType gradeType, + CylinderType cylinderType, + MotorType engineType) + : base( + price, + weight, + acceleration, + topSpeed, + gradeType) + { + this.horsepower = horsepower; + this.cylinderType = cylinderType; + this.engineType = engineType; + } + + public int Horsepower + { + get { return this.horsepower; } + } + + public MotorType EngineType + { + get + { + return this.engineType; + } + } + + public CylinderType CylinderType + { + get + { + return this.cylinderType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/CentaurPulseMotor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/CentaurPulseMotor.cs new file mode 100644 index 0000000..a126ae5 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/CentaurPulseMotor.cs @@ -0,0 +1,28 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Motors.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors +{ + public class CentaurPulseMotor : Motor, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int CentaurPulseMotorWeightInGrams = 175000; + private const int CentaurPulseMotorAccelerationBonus = 50; + private const int CentaurPulseMotorTopSpeedBonus = 180; + private const int CentaurPulseMotorHorsepower = 480; + private const decimal CentaurPulseMotorPriceInUSADollars = 5999; + + public CentaurPulseMotor() + : base( + CentaurPulseMotorPriceInUSADollars, + CentaurPulseMotorWeightInGrams, + CentaurPulseMotorAccelerationBonus, + CentaurPulseMotorTopSpeedBonus, + CentaurPulseMotorHorsepower, + TunningGradeType.MidGrade, + CylinderType.V6, + MotorType.PulseDetonationMotor) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/HellcatMotor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/HellcatMotor.cs new file mode 100644 index 0000000..a62e001 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/HellcatMotor.cs @@ -0,0 +1,28 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Motors.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors +{ + public class HellcatMotor : Motor, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int HellcatMotorWeightInGrams = 145000; + private const int HellcatMotorAccelerationBonus = 75; + private const int HellcatMotorTopSpeedBonus = 250; + private const int HellcatMotorHorsepower = 760; + private const decimal HellcatMotorPriceInUSADollars = 14599; + + public HellcatMotor() + : base( + HellcatMotorPriceInUSADollars, + HellcatMotorWeightInGrams, + HellcatMotorAccelerationBonus, + HellcatMotorTopSpeedBonus, + HellcatMotorHorsepower, + TunningGradeType.HighGrade, + CylinderType.V16, + MotorType.SabreReactionMotor) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/IronHorseMotor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/IronHorseMotor.cs new file mode 100644 index 0000000..c128866 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/IronHorseMotor.cs @@ -0,0 +1,28 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Motors.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors +{ + public class IronHorseMotor : Motor, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int IronHorseMotorWeightInGrams = 180000; + private const int IronHorseMotorAccelerationBonus = 70; + private const int IronHorseMotorTopSpeedBonus = 130; + private const int IronHorseMotorHorsepower = 350; + private const decimal IronHorseMotorPriceInUSADollars = 6399; + + public IronHorseMotor() + : base( + IronHorseMotorPriceInUSADollars, + IronHorseMotorWeightInGrams, + IronHorseMotorAccelerationBonus, + IronHorseMotorTopSpeedBonus, + IronHorseMotorHorsepower, + TunningGradeType.MidGrade, + CylinderType.V8, + MotorType.SteamMotor) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/ShockblazePulsejetMotor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/ShockblazePulsejetMotor.cs new file mode 100644 index 0000000..edd6208 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/ShockblazePulsejetMotor.cs @@ -0,0 +1,28 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Motors.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors +{ + public class ShockblazePulsejetMotor : Motor, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int ShockblazePulsejetMotorWeightInGrams = 150000; + private const int ShockblazePulsejetMotorAccelerationBonus = 80; + private const int ShockblazePulsejetMotorTopSpeedBonus = 220; + private const int ShockblazePulsejetMotorHorsepower = 700; + private const decimal ShockblazePulsejetMotorPriceInUSADollars = 12899; + + public ShockblazePulsejetMotor() + : base( + ShockblazePulsejetMotorPriceInUSADollars, + ShockblazePulsejetMotorWeightInGrams, + ShockblazePulsejetMotorAccelerationBonus, + ShockblazePulsejetMotorTopSpeedBonus, + ShockblazePulsejetMotorHorsepower, + TunningGradeType.HighGrade, + CylinderType.V16, + MotorType.PulseJet) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/StingrayMotor.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/StingrayMotor.cs new file mode 100644 index 0000000..4d37f05 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/StingrayMotor.cs @@ -0,0 +1,28 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Motors.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors +{ + public class StingrayMotor : Motor, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int StingrayMotorWeightInGrams = 158000; + private const int StingrayMotorAccelerationBonus = 60; + private const int StingrayMotorTopSpeedBonus = 230; + private const int StingrayMotorHorsepower = 800; + private const decimal StingrayMotorPriceInUSADollars = 10899; + + public StingrayMotor() + : base( + StingrayMotorPriceInUSADollars, + StingrayMotorWeightInGrams, + StingrayMotorAccelerationBonus, + StingrayMotorTopSpeedBonus, + StingrayMotorHorsepower, + TunningGradeType.HighGrade, + CylinderType.V12, + MotorType.ReciprocatingMotor) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/TyphoonPulseEngine.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/TyphoonPulseEngine.cs new file mode 100644 index 0000000..73b3734 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Motors/TyphoonPulseEngine.cs @@ -0,0 +1,28 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Motors.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Motors +{ + public class TyphoonPulseMotor : Motor, IMotor, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int TyphoonPulseMotorWeightInGrams = 176000; + private const int TyphoonPulseMotorAccelerationBonus = 90; + private const int TyphoonPulseMotorTopSpeedBonus = 300; + private const int TyphoonPulseMotorHorsepower = 1200; + private const decimal TyphoonPulseMotorPriceInUSADollars = 15999; + + public TyphoonPulseMotor() + : base( + TyphoonPulseMotorPriceInUSADollars, + TyphoonPulseMotorWeightInGrams, + TyphoonPulseMotorAccelerationBonus, + TyphoonPulseMotorTopSpeedBonus, + TyphoonPulseMotorHorsepower, + TunningGradeType.HighGrade, + CylinderType.V16, + MotorType.PulseDetonationMotor) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/Abstract/RaceTrack.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/Abstract/RaceTrack.cs new file mode 100644 index 0000000..570f3c1 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/Abstract/RaceTrack.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using FastAndFurious.ConsoleApplication.Common.Constants; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Common; + +namespace FastAndFurious.ConsoleApplication.Models.Tracks.Abstract +{ + public class RaceTrack : IdentifiableObject, IRaceTrack + { + private readonly string trackName; + private readonly int maxParticipantsCount; + private readonly int minParticipantsCount; + private readonly int trackLengthInMeters; + private readonly ICollection participants; + private readonly ICollection> finishedRacesResults; + + public RaceTrack( + string trackName, + int maxParticipantsCount, + int minParticipantsCount, + int trackLengthInMeters) + { + this.trackName = trackName; + this.maxParticipantsCount = maxParticipantsCount; + this.minParticipantsCount = minParticipantsCount; + this.trackLengthInMeters = trackLengthInMeters; + this.participants = new List(); + this.finishedRacesResults = new List>(); + } + + public int MaxParticipantsCount + { + get + { + return this.maxParticipantsCount; + } + } + + public int MinParticipantsCount + { + get + { + return this.minParticipantsCount; + } + } + + public int TrackLengthInMeters + { + get + { + return this.trackLengthInMeters; + } + } + + public string TrackName + { + get + { + return this.trackName; + } + } + + public IEnumerable Participants + { + get + { + return this.participants; + } + } + + public IEnumerable> FinishedRacesResults + { + get + { + return this.finishedRacesResults; + } + } + + public void AddParticipant(IDriver participant) + { + if (this.participants.Any(x => x.Id == participant.Id)) + { + throw new InvalidOperationException(GlobalConstants.DriverCannotBeSignedForRaceTrackParticipantMoreThanOnceExceptionMessage); + } + if (this.participants.Count > this.MaxParticipantsCount) + { + throw new InvalidOperationException(GlobalConstants.CannotAddMoreParticipantsToRaceTrack); + } + + this.participants.Add(participant); + } + + public bool RemoveParticipant(IDriver participant) + { + return this.participants.Remove(participant); + } + + public void RunRace() + { + var participantsCount = this.participants.Count(); + + if (this.MinParticipantsCount <= participantsCount) + { + // TODO: STIMPL + var raceResults = new List(participantsCount); + foreach (var participant in this.Participants) + { + var timeRequiredToFinishTheTrack = participant.ActiveVehicle.Race(this.TrackLengthInMeters); + raceResults.Add(timeRequiredToFinishTheTrack); + } + + this.finishedRacesResults.Add(raceResults); + this.participants.Clear(); + } + else + { + Console.WriteLine(String.Format(GlobalConstants.CannotStartRaceMessage, participantsCount)); + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/IndianapolisRaceTrack.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/IndianapolisRaceTrack.cs new file mode 100644 index 0000000..fc92366 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/IndianapolisRaceTrack.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FastAndFurious.ConsoleApplication.Models.Tracks.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tracks +{ + public class IndianapolisRaceTrack : RaceTrack + { + private const string IndianapolisRaceTrackName = "Indianapolis Race Track"; + private const int IndianapolisRaceTrackMaxParticipantsCount = 7; + private const int IndianapolisRaceTrackMinParticipantsCount = 2; + private const int IndianapolisRaceTrackTrackLengthInMeters = 12000; + + public IndianapolisRaceTrack() + : base( + IndianapolisRaceTrackName, + IndianapolisRaceTrackMaxParticipantsCount, + IndianapolisRaceTrackMinParticipantsCount, + IndianapolisRaceTrackTrackLengthInMeters) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/MonacoRaceTrack.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/MonacoRaceTrack.cs new file mode 100644 index 0000000..0ec43b9 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/MonacoRaceTrack.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FastAndFurious.ConsoleApplication.Models.Tracks.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tracks +{ + public class MonacoRaceTrack : RaceTrack + { + private const string MonacoRaceTrackName = "Monaco Race Track"; + private const int MonacoRaceTrackMaxParticipantsCount = 5; + private const int MonacoRaceTrackMinParticipantsCount = 2; + private const int MonacoRaceTrackTrackLengthInMeters = 2000; + + public MonacoRaceTrack() + : base( + MonacoRaceTrackName, + MonacoRaceTrackMaxParticipantsCount, + MonacoRaceTrackMinParticipantsCount, + MonacoRaceTrackTrackLengthInMeters) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/StormblazeRaceTrack.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/StormblazeRaceTrack.cs new file mode 100644 index 0000000..ff24502 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/StormblazeRaceTrack.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FastAndFurious.ConsoleApplication.Models.Tracks.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tracks +{ + public class StormblazeRaceTrack : RaceTrack + { + private const string StormblazeRaceTrackName = "Stormblaze Race Track"; + private const int StormblazeRaceTrackMaxParticipantsCount = 4; + private const int StormblazeRaceTrackMinParticipantsCount = 2; + private const int StormblazeRaceTrackLengthInMeters = 1000; + + public StormblazeRaceTrack() + : base( + StormblazeRaceTrackName, + StormblazeRaceTrackMaxParticipantsCount, + StormblazeRaceTrackMinParticipantsCount, + StormblazeRaceTrackLengthInMeters) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/TokioUndergroundRaceTrack.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/TokioUndergroundRaceTrack.cs new file mode 100644 index 0000000..5a8ad88 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tracks/TokioUndergroundRaceTrack.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FastAndFurious.ConsoleApplication.Models.Tracks.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tracks +{ + public class TokioUndergroundRaceTrack : RaceTrack + { + private const string TokioUndergroundRaceTrackName = "Tokio Underground Race Track"; + private const int TokioUndergroundRaceTrackMaxParticipantsCount = 8; + private const int TokioUndergroundRaceTrackMinParticipantsCount = 2; + private const int TokioUndergroundRaceTrackTrackLengthInMeters = 5000; + + public TokioUndergroundRaceTrack() + : base( + TokioUndergroundRaceTrackName, + TokioUndergroundRaceTrackMaxParticipantsCount, + TokioUndergroundRaceTrackMinParticipantsCount, + TokioUndergroundRaceTrackTrackLengthInMeters) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Abstract/TunningPart.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Abstract/TunningPart.cs new file mode 100644 index 0000000..bebd5ca --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Abstract/TunningPart.cs @@ -0,0 +1,65 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Common; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract +{ + public abstract class TunningPart : IdentifiableObject, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly int id; + private readonly int weight; + private readonly int acceleration; + private readonly int topSpeed; + private readonly decimal price; + private readonly TunningGradeType gradeType; + + public TunningPart( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType gradeType) + { + this.acceleration = acceleration; + this.topSpeed = topSpeed; + this.price = price; + this.gradeType = gradeType; + } + + public int Weight + { + get + { + return this.weight; + } + } + public int Acceleration + { + get + { + return this.acceleration; + } + } + public int TopSpeed + { + get + { + return this.topSpeed; + } + } + public decimal Price + { + get + { + return this.price; + } + } + public TunningGradeType GradeType + { + get + { + return this.gradeType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/APREngineControlUnit.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/APREngineControlUnit.cs new file mode 100644 index 0000000..59b1d34 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/APREngineControlUnit.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits +{ + public class APREngineControlUnit : EngineControlUnit, IEngineControlUnit, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int APREngineControlUnitWeightInGrams = 22000; + private const int APREngineControlUnitAccelerationBonus = 45; + private const int APREngineControlUnitTopSpeedBonus = 75; + private const decimal APREngineControlUnitPriceInUSADollars = 5789; + + public APREngineControlUnit() + : base( + APREngineControlUnitPriceInUSADollars, + APREngineControlUnitWeightInGrams, + APREngineControlUnitAccelerationBonus, + APREngineControlUnitTopSpeedBonus, + TunningGradeType.HighGrade, + EngineControlUnitType.Pro) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/Abstract/EngineControlUnit.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/Abstract/EngineControlUnit.cs new file mode 100644 index 0000000..f1c4ade --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/Abstract/EngineControlUnit.cs @@ -0,0 +1,35 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits.Abstract +{ + public abstract class EngineControlUnit : TunningPart, IEngineControlUnit, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private EngineControlUnitType engineControlUnitType; + + public EngineControlUnit( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType gradeType, + EngineControlUnitType engineControlUnitType) + : base( + price, + weight, + acceleration, + topSpeed, + gradeType) + { + } + + public EngineControlUnitType EngineControlUnitType + { + get + { + return this.engineControlUnitType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/DinanEngineControlUnit.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/DinanEngineControlUnit.cs new file mode 100644 index 0000000..d49cbcb --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/DinanEngineControlUnit.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits +{ + public class DinanEngineControlUnit : EngineControlUnit, IEngineControlUnit, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int DinanEngineControlUnitWeightInGrams = 19000; + private const int DinanEngineControlUnitAccelerationBonus = 35; + private const int DinanEngineControlUnitTopSpeedBonus = 65; + private const decimal DinanEngineControlUnitPriceInUSADollars = 4999; + + public DinanEngineControlUnit() + : base( + DinanEngineControlUnitPriceInUSADollars, + DinanEngineControlUnitWeightInGrams, + DinanEngineControlUnitAccelerationBonus, + DinanEngineControlUnitTopSpeedBonus, + TunningGradeType.MidGrade, + EngineControlUnitType.Performance) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/SCTPerformanceEngineControlUnit.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/SCTPerformanceEngineControlUnit.cs new file mode 100644 index 0000000..8c4889a --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/EngineControlUnits/SCTPerformanceEngineControlUnit.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.EngineControlUnits +{ + public class SCTPerformanceEngineControlUnit : EngineControlUnit, IEngineControlUnit, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int SCTPerformanceEngineControlUnitWeightInGrams = 21000; + private const int SCTPerformanceEngineControlUnitAccelerationBonus = 25; + private const int SCTPerformanceEngineControlUnitTopSpeedBonus = 45; + private const decimal SCTPerformanceEngineControlUnitPriceInUSADollars = 3599; + + public SCTPerformanceEngineControlUnit() + : base( + SCTPerformanceEngineControlUnitPriceInUSADollars, + SCTPerformanceEngineControlUnitWeightInGrams, + SCTPerformanceEngineControlUnitAccelerationBonus, + SCTPerformanceEngineControlUnitTopSpeedBonus, + TunningGradeType.LowGrade, + EngineControlUnitType.Stock) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/Abstract/Exhaust.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/Abstract/Exhaust.cs new file mode 100644 index 0000000..0e438cc --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/Abstract/Exhaust.cs @@ -0,0 +1,36 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystems.Abstract +{ + public abstract class Exhaust : TunningPart, IExhaust, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly ExhaustType exhaustType; + + public Exhaust( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType gradeType, + ExhaustType exhaustType) + : base( + price, + weight, + acceleration, + topSpeed, + gradeType) + { + this.exhaustType = exhaustType; + } + + public ExhaustType ExhaustType + { + get + { + return this.exhaustType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/BorlaExhaust.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/BorlaExhaust.cs new file mode 100644 index 0000000..5117c42 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/BorlaExhaust.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystems.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystems +{ + public class BorlaExhaust : Exhaust, IExhaust, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int BorlaExhaustWeightInGrams = 14600; + private const int BorlaExhaustAccelerationBonus = 12; + private const int BorlaExhaustTopSpeedBonus = 40; + private const decimal BorlaExhaustPriceInUSADollars = 1299; + + public BorlaExhaust() + : base( + BorlaExhaustPriceInUSADollars, + BorlaExhaustWeightInGrams, + BorlaExhaustAccelerationBonus, + BorlaExhaustTopSpeedBonus, + TunningGradeType.HighGrade, + ExhaustType.CeramicCoated) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/MagnaflowExhaust.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/MagnaflowExhaust.cs new file mode 100644 index 0000000..aff2df6 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/MagnaflowExhaust.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystems.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystems +{ + public class MagnaflowExhaust : Exhaust, IExhaust, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int MagnaflowExhaustWeightInGrams = 12800; + private const int MagnaflowExhaustAccelerationBonus = 5; + private const int MagnaflowExhaustTopSpeedBonus = 25; + private const decimal MagnaflowExhaustPriceInUSADollars = 379; + + public MagnaflowExhaust() + : base( + MagnaflowExhaustPriceInUSADollars, + MagnaflowExhaustWeightInGrams, + MagnaflowExhaustAccelerationBonus, + MagnaflowExhaustTopSpeedBonus, + TunningGradeType.LowGrade, + ExhaustType.NickelChromePlated) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/RemusExhaust.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/RemusExhaust.cs new file mode 100644 index 0000000..3c9b2ed --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/ExhaustSystems/RemusExhaust.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystems.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.ExhaustSystem +{ + public class RemusExhaust : Exhaust, IExhaust, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int RemusExhaustWeightInGrams = 11500; + private const int RemusExhaustAccelerationBonus = 8; + private const int RemusExhaustTopSpeedBonus = 32; + private const decimal RemusExhaustPriceInUSADollars = 679; + + public RemusExhaust() + : base( + RemusExhaustPriceInUSADollars, + RemusExhaustWeightInGrams, + RemusExhaustAccelerationBonus, + RemusExhaustTopSpeedBonus, + TunningGradeType.MidGrade, + ExhaustType.StainlessSteel) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/Abstract/Intercooler.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/Abstract/Intercooler.cs new file mode 100644 index 0000000..b741040 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/Abstract/Intercooler.cs @@ -0,0 +1,36 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Intercoolers.Abstract +{ + public abstract class Intercooler : TunningPart, IIntercooler, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly IntercoolerType intercoolerType; + + public Intercooler( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType gradeType, + IntercoolerType intercoolerType) + : base( + price, + weight, + acceleration, + topSpeed, + gradeType) + { + this.intercoolerType = intercoolerType; + } + + public IntercoolerType IntercoolerType + { + get + { + return this.intercoolerType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/EvolutionXPerformanceIntercooler.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/EvolutionXPerformanceIntercooler.cs new file mode 100644 index 0000000..1ac3a30 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/EvolutionXPerformanceIntercooler.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Intercoolers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Intercoolers +{ + public class EvolutionXPerformanceIntercooler : Intercooler, IIntercooler, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int EvolutionXPerformanceIntercoolerWeightInGrams = 4500; + private const int EvolutionXPerformanceIntercoolerAccelerationBonus = -5; + private const int EvolutionXPerformanceIntercoolerTopSpeedBonus = 40; + private const decimal EvolutionXPerformanceIntercoolerPriceInUSADollars = 499; + + public EvolutionXPerformanceIntercooler() + : base( + EvolutionXPerformanceIntercoolerPriceInUSADollars, + EvolutionXPerformanceIntercoolerWeightInGrams, + EvolutionXPerformanceIntercoolerAccelerationBonus, + EvolutionXPerformanceIntercoolerTopSpeedBonus, + TunningGradeType.HighGrade, + IntercoolerType.AirToLiquidIntercooler) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/ViperGenieIntercooler.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/ViperGenieIntercooler.cs new file mode 100644 index 0000000..3da3f66 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Intercoolers/ViperGenieIntercooler.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Intercoolers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Intercoolers +{ + public class ViperGenieIntercooler : Intercooler, IIntercooler, ITunningPart, IWeightable + { + private const int ViperGenieIntercoolerWeightInGrams = 5300; + private const int ViperGenieIntercoolerAccelerationBonus = 0; + private const int ViperGenieIntercoolerTopSpeedBonus = 25; + private const decimal ViperGenieIntercoolerPriceInUSADollars = 289; + + public ViperGenieIntercooler() + : base( + ViperGenieIntercoolerPriceInUSADollars, + ViperGenieIntercoolerWeightInGrams, + ViperGenieIntercoolerAccelerationBonus, + ViperGenieIntercoolerTopSpeedBonus, + TunningGradeType.MidGrade, + IntercoolerType.ChargeAirIntercooler) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/Abstract/TireSet.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/Abstract/TireSet.cs new file mode 100644 index 0000000..311196a --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/Abstract/TireSet.cs @@ -0,0 +1,35 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Tires.Abstract +{ + public abstract class TiresSet : TunningPart, ITunningPart, ITireSet, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly TireType tireType; + + public TiresSet( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType gradeType, + TireType tireType) + : base( + price, + weight, + acceleration, + topSpeed, + gradeType) + { + } + + public TireType TireType + { + get + { + return this.tireType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/FalkenAzenisTiresSet.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/FalkenAzenisTiresSet.cs new file mode 100644 index 0000000..04a5628 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/FalkenAzenisTiresSet.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Tires.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Tires +{ + public class FalkenAzenisTiresSet : TiresSet, ITunningPart, ITireSet, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int FalkenAzenisTireWeightInGrams = 7800; + private const int FalkenAzenisTireAccelerationBonus = 3; + private const int FalkenAzenisTireTopSpeedBonus = 0; + private const decimal FalkenAzenisTirePriceInUSADollars = 359; + + public FalkenAzenisTiresSet() + : base( + FalkenAzenisTirePriceInUSADollars, + FalkenAzenisTireWeightInGrams, + FalkenAzenisTireAccelerationBonus, + FalkenAzenisTireTopSpeedBonus, + TunningGradeType.LowGrade, + TireType.OffRoadTire) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/MichelinPilotTiresSet.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/MichelinPilotTiresSet.cs new file mode 100644 index 0000000..59a4243 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/MichelinPilotTiresSet.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Tires.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Tires +{ + public class MichelinPilotTiresSet : TiresSet, ITunningPart, ITireSet, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int MichelinPilotTireWeightInGrams = 6500; + private const int MichelinPilotTireAccelerationBonus = 7; + private const int MichelinPilotTireTopSpeedBonus = 1; + private const decimal MichelinPilotTirePriceInUSADollars = 1399; + + public MichelinPilotTiresSet() + : base( + MichelinPilotTirePriceInUSADollars, + MichelinPilotTireWeightInGrams, + MichelinPilotTireAccelerationBonus, + MichelinPilotTireTopSpeedBonus, + TunningGradeType.HighGrade, + TireType.PerformanceTire) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/YokohamaAdvanTiresSet.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/YokohamaAdvanTiresSet.cs new file mode 100644 index 0000000..8fcfcf6 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Tires/YokohamaAdvanTiresSet.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Tires.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Tires +{ + public class YokohamaAdvanTiresSet : TiresSet, ITunningPart, ITireSet, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int YokohamaAdvanTireWeightInGrams = 6600; + private const int YokohamaAdvanTireAccelerationBonus = 5; + private const int YokohamaAdvanTireTopSpeedBonus = 1; + private const decimal YokohamaAdvanTirePriceInUSADollars = 589; + + public YokohamaAdvanTiresSet() + : base( + YokohamaAdvanTirePriceInUSADollars, + YokohamaAdvanTireWeightInGrams, + YokohamaAdvanTireAccelerationBonus, + YokohamaAdvanTireTopSpeedBonus, + TunningGradeType.MidGrade, + TireType.AllTerrainTire) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/Abstract/Transmission.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/Abstract/Transmission.cs new file mode 100644 index 0000000..ba4205b --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/Abstract/Transmission.cs @@ -0,0 +1,31 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions.Abstract +{ + public abstract class Transmission : TunningPart, ITransmission, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly TransmissionType transmissionType; + + public Transmission( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType gradeType, + TransmissionType transmissionType) + : base(price, weight, acceleration, topSpeed, gradeType) + { + this.transmissionType = transmissionType; + } + + public TransmissionType TransmissionType + { + get + { + return this.transmissionType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/BMShortShifter.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/BMShortShifter.cs new file mode 100644 index 0000000..ef693c0 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/BMShortShifter.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions +{ + public class BMShortShifter : Transmission, ITransmission, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int BMShortShifterWeightInGrams = 5700; + private const int BMShortShifterAccelerationBonus = 28; + private const int BMShortShifterTopSpeedBonus = 0; + private const decimal BMShortShifterPriceInUSADollars = 2799; + + public BMShortShifter() + : base( + BMShortShifterPriceInUSADollars, + BMShortShifterWeightInGrams, + BMShortShifterAccelerationBonus, + BMShortShifterTopSpeedBonus, + TunningGradeType.HighGrade, + TransmissionType.ManualShortShifter) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/HurstCompetitionManualShifter.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/HurstCompetitionManualShifter.cs new file mode 100644 index 0000000..93680b0 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/HurstCompetitionManualShifter.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions +{ + public class HurstCompetitionManualShifter : Transmission, ITransmission, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int HurstCompetitionManualShifterWeightInGrams = 6000; + private const int HurstCompetitionManualShifterAccelerationBonus = 20; + private const int HurstCompetitionManualShifterTopSpeedBonus = 0; + private const decimal HurstCompetitionManualShifterPriceInUSADollars = 1999; + + public HurstCompetitionManualShifter() + : base( + HurstCompetitionManualShifterPriceInUSADollars, + HurstCompetitionManualShifterWeightInGrams, + HurstCompetitionManualShifterAccelerationBonus, + HurstCompetitionManualShifterTopSpeedBonus, + TunningGradeType.MidGrade, + TransmissionType.StockShifter) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/TWMPerformanceTransmission.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/TWMPerformanceTransmission.cs new file mode 100644 index 0000000..cb29a26 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Transmissions/TWMPerformanceTransmission.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Transmissions +{ + public class TWMPerformanceTransmission : Transmission, ITransmission, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int TWMPerformanceTransmissionWeightInGrams = 4799; + private const int TWMPerformanceTransmissionAccelerationBonus = 15; + private const int TWMPerformanceTransmissionTopSpeedBonus = 0; + private const decimal TWMPerformanceTransmissionPriceInUSADollars = 1599; + + public TWMPerformanceTransmission() + : base( + TWMPerformanceTransmissionPriceInUSADollars, + TWMPerformanceTransmissionWeightInGrams, + TWMPerformanceTransmissionAccelerationBonus, + TWMPerformanceTransmissionTopSpeedBonus, + TunningGradeType.LowGrade, + TransmissionType.SemiManualShifter) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/Abstract/Turbocharger.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/Abstract/Turbocharger.cs new file mode 100644 index 0000000..2c5c352 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/Abstract/Turbocharger.cs @@ -0,0 +1,36 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Turbochargers.Abstract +{ + public abstract class Turbocharger : TunningPart, ITurbocharger, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private readonly TurbochargerType turbochargerType; + + public Turbocharger( + decimal price, + int weight, + int acceleration, + int topSpeed, + TunningGradeType grade, + TurbochargerType turbochargerType) + : base( + price, + weight, + acceleration, + topSpeed, + grade) + { + this.turbochargerType = turbochargerType; + } + + public TurbochargerType TurbochargerType + { + get + { + return this.turbochargerType; + } + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/VortexR35SequentialTurbocharger.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/VortexR35SequentialTurbocharger.cs new file mode 100644 index 0000000..12108ad --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/VortexR35SequentialTurbocharger.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Turbochargers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Turbochargers +{ + public class VortexR35SequentialTurbocharger : Turbocharger, ITurbocharger + { + private const int VortexR35SequentialTurbochargerWeightInGrams = 3900; + private const int VortexR35SequentialTurbochargerAccelerationBonus = 10; + private const int VortexR35SequentialTurbochargerTopSpeedBonus = 85; + private const decimal VortexR35SequentialTurbochargerPriceInUSADollars = 699; + + public VortexR35SequentialTurbocharger() + : base( + VortexR35SequentialTurbochargerPriceInUSADollars, + VortexR35SequentialTurbochargerWeightInGrams, + VortexR35SequentialTurbochargerAccelerationBonus, + VortexR35SequentialTurbochargerTopSpeedBonus, + TunningGradeType.HighGrade, + TurbochargerType.SequentialTurbo) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/ZX8ParallelTwinTurbocharger.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/ZX8ParallelTwinTurbocharger.cs new file mode 100644 index 0000000..2cf8dd3 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Models/Tunnings/Turbochargers/ZX8ParallelTwinTurbocharger.cs @@ -0,0 +1,25 @@ +using FastAndFurious.ConsoleApplication.Common.Enums; +using FastAndFurious.ConsoleApplication.Contracts; +using FastAndFurious.ConsoleApplication.Models.Tunnings.Turbochargers.Abstract; + +namespace FastAndFurious.ConsoleApplication.Models.Tunnings.Turbochargers +{ + public class ZX8ParallelTwinTurbocharger : Turbocharger, ITurbocharger, ITunningPart, IAccelerateable, ITopSpeed, IWeightable, IValuable, IIdentifiable + { + private const int ZX8ParallelTwinTurbochargerWeightInGrams = 3500; + private const int ZX8ParallelTwinTurbochargerAccelerationBonus = 15; + private const int ZX8ParallelTwinTurbochargerTopSpeedBonus = 60; + private const decimal ZX8ParallelTwinTurbochargerPriceInUSADollars = 799; + + public ZX8ParallelTwinTurbocharger() + : base( + ZX8ParallelTwinTurbochargerPriceInUSADollars, + ZX8ParallelTwinTurbochargerWeightInGrams, + ZX8ParallelTwinTurbochargerAccelerationBonus, + ZX8ParallelTwinTurbochargerTopSpeedBonus, + TunningGradeType.HighGrade, + TurbochargerType.TwinTurbo) + { + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Properties/AssemblyInfo.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3ab1776 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FastAndFurious.ConsoleApplication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FastAndFurious.ConsoleApplication")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b77babfa-3ba7-4fc2-9955-63572d999dc7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Startup.cs b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Startup.cs new file mode 100644 index 0000000..eb68e48 --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.ConsoleApplication/Startup.cs @@ -0,0 +1,11 @@ +namespace FastAndFurious.ConsoleApplication +{ + public class Startup + { + public static void Main(string[] args) + { + var engine = new FastAndFurious.ConsoleApplication.Engine.Engine(); + engine.Start(); + } + } +} diff --git a/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.sln b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.sln new file mode 100644 index 0000000..2b7781d --- /dev/null +++ b/Topics/Exam-AuthorsSolutions/FastAndFurious-AuthorSolution/FastAndFurious.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastAndFurious.ConsoleApplication", "FastAndFurious.ConsoleApplication\FastAndFurious.ConsoleApplication.csproj", "{B77BABFA-3BA7-4FC2-9955-63572D999DC7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B77BABFA-3BA7-4FC2-9955-63572D999DC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B77BABFA-3BA7-4FC2-9955-63572D999DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B77BABFA-3BA7-4FC2-9955-63572D999DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B77BABFA-3BA7-4FC2-9955-63572D999DC7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal