Skip to content

Commit b7b7071

Browse files
committed
Skeleton added
1 parent cb5ccf5 commit b7b7071

34 files changed

+1021
-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 2013
4+
VisualStudioVersion = 12.0.30723.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmetics", "Cosmetics\Cosmetics.csproj", "{B005C0B3-5C89-45A7-9BE1-FAB966806F40}"
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+
{B005C0B3-5C89-45A7-9BE1-FAB966806F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B005C0B3-5C89-45A7-9BE1-FAB966806F40}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B005C0B3-5C89-45A7-9BE1-FAB966806F40}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B005C0B3-5C89-45A7-9BE1-FAB966806F40}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Cosmetics.Contracts;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Cosmetics.Cart
9+
{
10+
public class ShoppingCart
11+
{
12+
private ICollection<IProduct> productList;
13+
14+
public ShoppingCart()
15+
{
16+
this.ProductList = null;
17+
}
18+
19+
public ICollection<IProduct> ProductList
20+
{
21+
get { return this.productList; }
22+
set { productList = value; }
23+
}
24+
25+
public void AddProduct(IProduct product)
26+
{
27+
throw new NotImplementedException();
28+
}
29+
30+
public void RemoveProduct(IProduct product)
31+
{
32+
throw new NotImplementedException();
33+
}
34+
35+
public bool ContainsProduct(IProduct product)
36+
{
37+
throw new NotImplementedException();
38+
}
39+
40+
public decimal TotalPrice()
41+
{
42+
throw new NotImplementedException();
43+
}
44+
}
45+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Cosmetics.Common
2+
{
3+
public enum GenderType
4+
{
5+
Men,
6+
Women,
7+
Unisex
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Cosmetics.Common
2+
{
3+
public class GlobalErrorMessages
4+
{
5+
public const string StringCannotBeNullOrEmpty = "{0} cannot be null or empty!";
6+
public const string ObjectCannotBeNull = "{0} cannot be null!";
7+
public const string InvalidStringLength = "{0} must be between {1} and {2} symbols long!";
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Cosmetics.Common
2+
{
3+
public enum UsageType
4+
{
5+
EveryDay,
6+
Medical
7+
}
8+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace Cosmetics.Common
2+
{
3+
using System;
4+
5+
public static class Validator
6+
{
7+
public static void CheckIfNull(object obj, string message = null)
8+
{
9+
if (obj == null)
10+
{
11+
throw new NullReferenceException(message);
12+
}
13+
}
14+
15+
public static void CheckIfStringIsNullOrEmpty(string text, string message = null)
16+
{
17+
if (string.IsNullOrEmpty(text))
18+
{
19+
throw new NullReferenceException(message);
20+
}
21+
}
22+
23+
public static void CheckIfStringLengthIsValid(string text, int max, int min = 0, string message = null)
24+
{
25+
if (text.Length < min || max < text.Length)
26+
{
27+
throw new IndexOutOfRangeException(message);
28+
}
29+
}
30+
}
31+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
public interface ICategory
4+
{
5+
string Name { get; }
6+
7+
void AddCosmetics(IProduct cosmetics);
8+
9+
void RemoveCosmetics(IProduct cosmetics);
10+
11+
string Print();
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
using System.Collections.Generic;
4+
5+
interface ICommand
6+
{
7+
string Name { get; }
8+
9+
IList<string> Parameters { get; }
10+
}
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
using System.Collections.Generic;
4+
5+
using Cosmetics.Common;
6+
using Cart;
7+
using Products;
8+
9+
public interface ICosmeticsFactory
10+
{
11+
ICategory CreateCategory(string name);
12+
13+
Shampoo CreateShampoo(string name, string brand, decimal price, GenderType gender, uint milliliters, UsageType usage);
14+
15+
IToothpaste CreateToothpaste(string name, string brand, decimal price, GenderType gender, IList<string> ingredients);
16+
17+
ShoppingCart ShoppingCart();
18+
}
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
public interface IEngine
4+
{
5+
void Start();
6+
}
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
using Cosmetics.Common;
4+
5+
public interface IProduct
6+
{
7+
string Name { get; }
8+
9+
string Brand { get; }
10+
11+
decimal Price { get; }
12+
13+
GenderType Gender { get; }
14+
15+
string Print();
16+
}
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
using Cosmetics.Common;
4+
5+
public interface IShampoo : IProduct
6+
{
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Cosmetics.Contracts
2+
{
3+
using System.Collections.Generic;
4+
5+
public interface IToothpaste : IProduct
6+
{
7+
string Ingredients { get; }
8+
}
9+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.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>{B005C0B3-5C89-45A7-9BE1-FAB966806F40}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Cosmetics</RootNamespace>
11+
<AssemblyName>Cosmetics</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="Common\GenderType.cs" />
45+
<Compile Include="Common\GlobalErrorMessages.cs" />
46+
<Compile Include="Common\UsageType.cs" />
47+
<Compile Include="Common\Validator.cs" />
48+
<Compile Include="Contracts\ICategory.cs" />
49+
<Compile Include="Contracts\ICommand.cs" />
50+
<Compile Include="Contracts\ICosmeticsFactory.cs" />
51+
<Compile Include="Contracts\IEngine.cs" />
52+
<Compile Include="Contracts\IProduct.cs" />
53+
<Compile Include="Contracts\IShampoo.cs" />
54+
<Compile Include="Contracts\IToothpaste.cs" />
55+
<Compile Include="CosmeticsProgram.cs" />
56+
<Compile Include="Engine\Command.cs" />
57+
<Compile Include="Engine\CosmeticsEngine.cs" />
58+
<Compile Include="Engine\CosmeticsFactory.cs" />
59+
<Compile Include="Products\Shampoo.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<Compile Include="Cart\ShoppingCart.cs" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<None Include="App.config" />
65+
</ItemGroup>
66+
<ItemGroup />
67+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
68+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
69+
Other similar extension points exist, see Microsoft.Common.targets.
70+
<Target Name="BeforeBuild">
71+
</Target>
72+
<Target Name="AfterBuild">
73+
</Target>
74+
-->
75+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Cosmetics.Engine;
2+
namespace Cosmetics
3+
{
4+
public class CosmeticsProgram
5+
{
6+
public static void Main()
7+
{
8+
CosmeticsEngine.Instance.Start();
9+
}
10+
}
11+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
namespace Cosmetics.Engine
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
6+
using Cosmetics.Contracts;
7+
8+
public class Command : ICommand
9+
{
10+
private const char SplitCommandSymbol = ' ';
11+
12+
private string name;
13+
private IList<string> parameters;
14+
15+
private Command(string input)
16+
{
17+
this.TranslateInput(input);
18+
}
19+
20+
public string Name
21+
{
22+
get
23+
{
24+
return this.name;
25+
}
26+
27+
private set
28+
{
29+
if (string.IsNullOrEmpty(value))
30+
{
31+
throw new ArgumentNullException("Name cannot be null or empty.");
32+
}
33+
34+
this.name = value;
35+
}
36+
}
37+
38+
public IList<string> Parameters
39+
{
40+
get
41+
{
42+
return this.parameters;
43+
}
44+
45+
private set
46+
{
47+
if (value == null)
48+
{
49+
throw new ArgumentNullException("List of strings cannot be null.");
50+
}
51+
52+
this.parameters = value;
53+
}
54+
}
55+
56+
public static Command Parse(string input)
57+
{
58+
return new Command(input);
59+
}
60+
61+
private void TranslateInput(string input)
62+
{
63+
var indexOfFirstSeparator = input.IndexOf(SplitCommandSymbol);
64+
65+
if (indexOfFirstSeparator < 0)
66+
{
67+
this.Name = input;
68+
return;
69+
}
70+
71+
this.Name = input.Substring(0, indexOfFirstSeparator);
72+
this.Parameters = input.Substring(indexOfFirstSeparator + 1).Split(new[] { SplitCommandSymbol }, StringSplitOptions.RemoveEmptyEntries);
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)