Skip to content

Commit 2a4a82a

Browse files
committed
Added author's solutions
1 parent b7f05dd commit 2a4a82a

File tree

116 files changed

+3842
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+3842
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.24720.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dealership", "Dealership\Dealership.csproj", "{4DB3664E-CDAE-446D-8163-683F6344C24B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4DB3664E-CDAE-446D-8163-683F6344C24B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
namespace Dealership.Common
2+
{
3+
public class Constants
4+
{
5+
// String lengths
6+
public const int MinNameLength = 2;
7+
public const int MaxNameLength = 20;
8+
public const int MinPasswordLength = 5;
9+
public const int MaxPasswordLength = 30;
10+
public const int MinCategoryLength = 3;
11+
public const int MaxCategoryLength = 10;
12+
public const int MinMakeLength = 2;
13+
public const int MaxMakeLength = 15;
14+
public const int MinModelLength = 1;
15+
public const int MaxModelLength = 15;
16+
public const int MinCommentLength = 3;
17+
public const int MaxCommentLength = 200;
18+
19+
// Numbers validation
20+
public const int MinWheels = 2;
21+
public const int MaxWheels = 10;
22+
public const decimal MinPrice = 0.0m;
23+
public const decimal MaxPrice = 1000000.0m;
24+
public const int MinSeats = 1;
25+
public const int MaxSeats = 10;
26+
public const int MinCapacity = 1;
27+
public const int MaxCapacity = 100;
28+
29+
// Strings for validation
30+
public const string StringMustBeBetweenMinAndMax = "{0} must be between {1} and {2} characters long!";
31+
public const string NumberMustBeBetweenMinAndMax = "{0} must be between {1} and {2}!";
32+
33+
// Vehicle max to add if not VIP
34+
public const int MaxVehiclesToAdd = 5;
35+
36+
// Username pattern
37+
public const string UsernamePattern = "^[A-Za-z0-9]+$";
38+
public const string PasswordPattern = "^[A-Za-z0-9@*_-]+$";
39+
40+
// Strings for vehicles, comments and users
41+
public const string InvalidSymbols = "{0} contains invalid symbols!";
42+
43+
public const string UserToString = "Username: {0}, FullName: {1} {2}, Role: {3}";
44+
45+
public const string CommentCannotBeNull = "Comment cannot be null!";
46+
public const string VehicleCannotBeNull = "Vehicle cannot be null!";
47+
48+
public const string NotAnVipUserVehiclesAdd = "You are not VIP and cannot add more than {0} vehicles!";
49+
public const string AdminCannotAddVehicles = "You are an admin and therefore cannot add vehicles!";
50+
51+
public const string YouAreNotTheAuthor = "You are not the author!";
52+
public const string UserCannotBeNull = "User cannot be null!";
53+
54+
// Added additionally
55+
public const string PropertyCannotBeNull = "{0} cannot be null!";
56+
57+
}
58+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Dealership.Common.Enums
2+
{
3+
public enum Role
4+
{
5+
Normal = 0,
6+
VIP = 1,
7+
Admin = 2
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Dealership.Common.Enums
2+
{
3+
public enum VehicleType
4+
{
5+
Motorcycle = 2,
6+
Car = 4,
7+
Truck = 8
8+
}
9+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace Dealership.Common
2+
{
3+
using System;
4+
using System.Text.RegularExpressions;
5+
6+
public static class Validator
7+
{
8+
public static void ValidateIntRange(int value, int min, int max, string message)
9+
{
10+
if (value < min || value > max)
11+
{
12+
throw new ArgumentException(message);
13+
}
14+
}
15+
16+
public static void ValidateDecimalRange(decimal value, decimal min, decimal max, string message)
17+
{
18+
if (value < min || value > max)
19+
{
20+
throw new ArgumentException(message);
21+
}
22+
}
23+
24+
public static void ValidateNull(object value, string message)
25+
{
26+
if (value == null)
27+
{
28+
throw new ArgumentNullException(message);
29+
}
30+
}
31+
32+
public static void ValidateSymbols(string value, string pattern, string message)
33+
{
34+
var regex = new Regex(pattern, RegexOptions.IgnoreCase);
35+
36+
if (!regex.IsMatch(value))
37+
{
38+
throw new ArgumentException(message);
39+
}
40+
}
41+
}
42+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Dealership.Contracts
2+
{
3+
public interface ICar
4+
{
5+
int Seats { get; }
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Dealership.Contracts
2+
{
3+
public interface IComment
4+
{
5+
string Content { get; }
6+
7+
string Author { get; set; }
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Collections.Generic;
2+
3+
namespace Dealership.Contracts
4+
{
5+
public interface ICommentable
6+
{
7+
IList<IComment> Comments { get; }
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Dealership.Contracts
2+
{
3+
public interface IMotorcycle
4+
{
5+
string Category { get; }
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Dealership.Contracts
2+
{
3+
public interface IPriceable
4+
{
5+
decimal Price { get; }
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Dealership.Contracts
2+
{
3+
public interface ITruck
4+
{
5+
int WeightCapacity { get; }
6+
}
7+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Dealership.Common.Enums;
2+
using System.Collections.Generic;
3+
4+
namespace Dealership.Contracts
5+
{
6+
public interface IUser
7+
{
8+
string Username { get; }
9+
10+
string FirstName { get; }
11+
12+
string LastName { get; }
13+
14+
string Password { get; }
15+
16+
Role Role { get; }
17+
18+
IList<IVehicle> Vehicles { get; }
19+
20+
void AddVehicle(IVehicle vehicle);
21+
22+
void RemoveVehicle(IVehicle vehicle);
23+
24+
void AddComment(IComment commentToAdd, IVehicle vehicleToAddComment);
25+
26+
void RemoveComment(IComment commentToRemove, IVehicle vehicleToRemoveComment);
27+
28+
string PrintVehicles();
29+
}
30+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Dealership.Contracts
2+
{
3+
using Dealership.Common.Enums;
4+
5+
public interface IVehicle : ICommentable, IPriceable
6+
{
7+
int Wheels { get; }
8+
9+
VehicleType Type { get; }
10+
11+
string Make { get; }
12+
13+
string Model { get; }
14+
}
15+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{4DB3664E-CDAE-446D-8163-683F6344C24B}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Dealership</RootNamespace>
11+
<AssemblyName>Dealership</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<PropertyGroup>
33+
<StartupObject />
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Common\Constants.cs" />
47+
<Compile Include="Common\Enums\VehicleType.cs" />
48+
<Compile Include="Common\Enums\Role.cs" />
49+
<Compile Include="Common\Validator.cs" />
50+
<Compile Include="Contracts\ICar.cs" />
51+
<Compile Include="Contracts\IComment.cs" />
52+
<Compile Include="Contracts\ICommentable.cs" />
53+
<Compile Include="Contracts\IMotorcycle.cs" />
54+
<Compile Include="Contracts\IPriceable.cs" />
55+
<Compile Include="Contracts\ITruck.cs" />
56+
<Compile Include="Contracts\IUser.cs" />
57+
<Compile Include="Contracts\IVehicle.cs" />
58+
<Compile Include="Engine\Command.cs" />
59+
<Compile Include="Engine\DealershipEngine.cs" />
60+
<Compile Include="Engine\ICommand.cs" />
61+
<Compile Include="Engine\IEngine.cs" />
62+
<Compile Include="Factories\DealershipFactory.cs" />
63+
<Compile Include="Factories\IDealershipFactory.cs" />
64+
<Compile Include="Models\Car.cs" />
65+
<Compile Include="Models\Comment.cs" />
66+
<Compile Include="Models\Motorcycle.cs" />
67+
<Compile Include="Models\Truck.cs" />
68+
<Compile Include="Models\User.cs" />
69+
<Compile Include="Models\Vehicle.cs" />
70+
<Compile Include="Properties\AssemblyInfo.cs" />
71+
<Compile Include="Startup.cs" />
72+
</ItemGroup>
73+
<ItemGroup />
74+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
75+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
76+
Other similar extension points exist, see Microsoft.Common.targets.
77+
<Target Name="BeforeBuild">
78+
</Target>
79+
<Target Name="AfterBuild">
80+
</Target>
81+
-->
82+
</Project>

0 commit comments

Comments
 (0)