├── .idea
└── .idea.DesignPatternFactory
│ └── .idea
│ ├── .gitignore
│ └── encodings.xml
├── Boat.cs
├── Bus.cs
├── Car.cs
├── DesignPatternFactory.csproj
├── DesignPatternFactory.sln
├── Program.cs
├── Vehicle.cs
├── VehicleCreator.cs
└── obj
├── Debug
├── net6.0
│ ├── .NETCoreApp,Version=v6.0.AssemblyAttributes.cs
│ ├── DesignPatternFactory.AssemblyInfo.cs
│ ├── DesignPatternFactory.AssemblyInfoInputs.cache
│ ├── DesignPatternFactory.GeneratedMSBuildEditorConfig.editorconfig
│ ├── DesignPatternFactory.assets.cache
│ └── DesignPatternFactory.csproj.AssemblyReference.cache
└── netcoreapp3.1
│ ├── .NETCoreApp,Version=v3.1.AssemblyAttributes.cs
│ ├── DesignPatternFactory.AssemblyInfo.cs
│ ├── DesignPatternFactory.AssemblyInfoInputs.cache
│ ├── DesignPatternFactory.GeneratedMSBuildEditorConfig.editorconfig
│ ├── DesignPatternFactory.assets.cache
│ └── DesignPatternFactory.csproj.AssemblyReference.cache
├── DesignPatternFactory.csproj.nuget.dgspec.json
├── DesignPatternFactory.csproj.nuget.g.props
├── DesignPatternFactory.csproj.nuget.g.targets
├── project.assets.json
├── project.nuget.cache
├── project.packagespec.json
└── rider.project.restore.info
/.idea/.idea.DesignPatternFactory/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /modules.xml
6 | /projectSettingsUpdater.xml
7 | /contentModel.xml
8 | /.idea.DesignPatternFactory.iml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/.idea/.idea.DesignPatternFactory/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Boat.cs:
--------------------------------------------------------------------------------
1 | namespace DesignPatternFactory
2 | {
3 | public class Boat : Vehicle
4 | {
5 | public Boat()
6 | {
7 | capacity = 150;
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Bus.cs:
--------------------------------------------------------------------------------
1 | namespace DesignPatternFactory
2 | {
3 | public class Bus : Vehicle
4 | {
5 | public Bus()
6 | {
7 | capacity = 50;
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Car.cs:
--------------------------------------------------------------------------------
1 | namespace DesignPatternFactory
2 | {
3 | public class Car : Vehicle
4 | {
5 | public Car()
6 | {
7 | capacity = 5;
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/DesignPatternFactory.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | 10
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DesignPatternFactory.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30406.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignPatternFactory", "DesignPatternFactory.csproj", "{4301179D-159F-4A4F-B89E-C500964C3A66}"
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 | {4301179D-159F-4A4F-B89E-C500964C3A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {4301179D-159F-4A4F-B89E-C500964C3A66}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {4301179D-159F-4A4F-B89E-C500964C3A66}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {4301179D-159F-4A4F-B89E-C500964C3A66}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {FB96C636-1DFA-4394-821D-3763DC2FF26B}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DesignPatternFactory
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | Console.WriteLine("Hello. How many passengers do you need?");
10 | int passengers = Convert.ToInt32(Console.ReadLine());
11 | var vehicle = VehicleCreator.GetVehicle(passengers);
12 | vehicle.AddPassengers(passengers);
13 | Console.WriteLine("Vehicle Type: " + vehicle.GetData() + ". With left capacity of: " + vehicle.GetCapacity());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Vehicle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DesignPatternFactory
4 | {
5 | public abstract class Vehicle
6 | {
7 | internal int capacity;
8 | public string GetData()
9 | {
10 | return GetType().ToString().Split(".")[1];
11 | }
12 | public int GetCapacity()
13 | {
14 | return capacity;
15 | }
16 | public void AddPassengers(int passengers)
17 | {
18 | if (capacity < passengers)
19 | {
20 | throw new Exception(GetData() +" reached max capacity");
21 | }
22 | else
23 | capacity -= passengers;
24 | }
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/VehicleCreator.cs:
--------------------------------------------------------------------------------
1 | namespace DesignPatternFactory
2 | {
3 | public class VehicleCreator
4 | {
5 | public static Vehicle GetVehicle(int passengers)
6 | {
7 | if (passengers <= 5)
8 | return new Car();
9 | if (passengers <= 50)
10 | return new Bus();
11 | return new Boat();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
5 |
--------------------------------------------------------------------------------
/obj/Debug/net6.0/DesignPatternFactory.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | using System;
11 | using System.Reflection;
12 |
13 | [assembly: System.Reflection.AssemblyCompanyAttribute("DesignPatternFactory")]
14 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
15 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
16 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
17 | [assembly: System.Reflection.AssemblyProductAttribute("DesignPatternFactory")]
18 | [assembly: System.Reflection.AssemblyTitleAttribute("DesignPatternFactory")]
19 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
20 |
21 | // Generated by the MSBuild WriteCodeFragment class.
22 |
23 |
--------------------------------------------------------------------------------
/obj/Debug/net6.0/DesignPatternFactory.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | 85caad19794b4e31d1b06612b9c4aab926fb4e2d
2 |
--------------------------------------------------------------------------------
/obj/Debug/net6.0/DesignPatternFactory.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework = net6.0
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.InvariantGlobalization =
7 | build_property.PlatformNeutralAssembly =
8 | build_property._SupportedPlatformList = Linux,macOS,Windows
9 | build_property.RootNamespace = DesignPatternFactory
10 | build_property.ProjectDir = E:\Repos\Articles-master\DesignPatterFactory\
11 |
--------------------------------------------------------------------------------
/obj/Debug/net6.0/DesignPatternFactory.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nirzaf/DesignPatternFactory/3108ead07c49cff1456fbe63f1ccf71b06ea5f16/obj/Debug/net6.0/DesignPatternFactory.assets.cache
--------------------------------------------------------------------------------
/obj/Debug/net6.0/DesignPatternFactory.csproj.AssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nirzaf/DesignPatternFactory/3108ead07c49cff1456fbe63f1ccf71b06ea5f16/obj/Debug/net6.0/DesignPatternFactory.csproj.AssemblyReference.cache
--------------------------------------------------------------------------------
/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
5 |
--------------------------------------------------------------------------------
/obj/Debug/netcoreapp3.1/DesignPatternFactory.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | using System;
11 | using System.Reflection;
12 |
13 | [assembly: System.Reflection.AssemblyCompanyAttribute("DesignPatternFactory")]
14 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
15 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
16 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
17 | [assembly: System.Reflection.AssemblyProductAttribute("DesignPatternFactory")]
18 | [assembly: System.Reflection.AssemblyTitleAttribute("DesignPatternFactory")]
19 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
20 |
21 | // Generated by the MSBuild WriteCodeFragment class.
22 |
23 |
--------------------------------------------------------------------------------
/obj/Debug/netcoreapp3.1/DesignPatternFactory.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | 85caad19794b4e31d1b06612b9c4aab926fb4e2d
2 |
--------------------------------------------------------------------------------
/obj/Debug/netcoreapp3.1/DesignPatternFactory.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.RootNamespace = DesignPatternFactory
3 | build_property.ProjectDir = E:\Repos\Articles-master\DesignPatterFactory\
4 |
--------------------------------------------------------------------------------
/obj/Debug/netcoreapp3.1/DesignPatternFactory.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nirzaf/DesignPatternFactory/3108ead07c49cff1456fbe63f1ccf71b06ea5f16/obj/Debug/netcoreapp3.1/DesignPatternFactory.assets.cache
--------------------------------------------------------------------------------
/obj/Debug/netcoreapp3.1/DesignPatternFactory.csproj.AssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nirzaf/DesignPatternFactory/3108ead07c49cff1456fbe63f1ccf71b06ea5f16/obj/Debug/netcoreapp3.1/DesignPatternFactory.csproj.AssemblyReference.cache
--------------------------------------------------------------------------------
/obj/DesignPatternFactory.csproj.nuget.dgspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": 1,
3 | "restore": {
4 | "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj": {}
5 | },
6 | "projects": {
7 | "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj": {
8 | "version": "1.0.0",
9 | "restore": {
10 | "projectUniqueName": "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj",
11 | "projectName": "DesignPatternFactory",
12 | "projectPath": "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj",
13 | "packagesPath": "C:\\Users\\Fazrin\\.nuget\\packages\\",
14 | "outputPath": "E:\\Repos\\Articles-master\\DesignPatterFactory\\obj\\",
15 | "projectStyle": "PackageReference",
16 | "configFilePaths": [
17 | "C:\\Users\\Fazrin\\AppData\\Roaming\\NuGet\\NuGet.Config",
18 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
19 | ],
20 | "originalTargetFrameworks": [
21 | "net6.0"
22 | ],
23 | "sources": {
24 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
25 | "https://api.nuget.org/v3/index.json": {}
26 | },
27 | "frameworks": {
28 | "net6.0": {
29 | "targetAlias": "net6.0",
30 | "projectReferences": {}
31 | }
32 | },
33 | "warningProperties": {
34 | "warnAsError": [
35 | "NU1605"
36 | ]
37 | }
38 | },
39 | "frameworks": {
40 | "net6.0": {
41 | "targetAlias": "net6.0",
42 | "imports": [
43 | "net461",
44 | "net462",
45 | "net47",
46 | "net471",
47 | "net472",
48 | "net48"
49 | ],
50 | "assetTargetFallback": true,
51 | "warn": true,
52 | "frameworkReferences": {
53 | "Microsoft.NETCore.App": {
54 | "privateAssets": "all"
55 | }
56 | },
57 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"
58 | }
59 | }
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/obj/DesignPatternFactory.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | $(MSBuildThisFileDirectory)project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\Fazrin\.nuget\packages\
9 | PackageReference
10 | 6.0.0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/obj/DesignPatternFactory.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/obj/project.assets.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "targets": {
4 | "net6.0": {}
5 | },
6 | "libraries": {},
7 | "projectFileDependencyGroups": {
8 | "net6.0": []
9 | },
10 | "packageFolders": {
11 | "C:\\Users\\Fazrin\\.nuget\\packages\\": {}
12 | },
13 | "project": {
14 | "version": "1.0.0",
15 | "restore": {
16 | "projectUniqueName": "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj",
17 | "projectName": "DesignPatternFactory",
18 | "projectPath": "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj",
19 | "packagesPath": "C:\\Users\\Fazrin\\.nuget\\packages\\",
20 | "outputPath": "E:\\Repos\\Articles-master\\DesignPatterFactory\\obj\\",
21 | "projectStyle": "PackageReference",
22 | "configFilePaths": [
23 | "C:\\Users\\Fazrin\\AppData\\Roaming\\NuGet\\NuGet.Config",
24 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
25 | ],
26 | "originalTargetFrameworks": [
27 | "net6.0"
28 | ],
29 | "sources": {
30 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
31 | "https://api.nuget.org/v3/index.json": {}
32 | },
33 | "frameworks": {
34 | "net6.0": {
35 | "targetAlias": "net6.0",
36 | "projectReferences": {}
37 | }
38 | },
39 | "warningProperties": {
40 | "warnAsError": [
41 | "NU1605"
42 | ]
43 | }
44 | },
45 | "frameworks": {
46 | "net6.0": {
47 | "targetAlias": "net6.0",
48 | "imports": [
49 | "net461",
50 | "net462",
51 | "net47",
52 | "net471",
53 | "net472",
54 | "net48"
55 | ],
56 | "assetTargetFallback": true,
57 | "warn": true,
58 | "frameworkReferences": {
59 | "Microsoft.NETCore.App": {
60 | "privateAssets": "all"
61 | }
62 | },
63 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/obj/project.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "dgSpecHash": "NzQlBkvUbkYA/vLzOp29GNdpLrA4YSgP2/in6t2Gv/05aYder/vxPo1lzkzjyZz+jx7gx+38kMHwoLIijqboUw==",
4 | "success": true,
5 | "projectFilePath": "E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj",
6 | "expectedPackageFiles": [],
7 | "logs": []
8 | }
--------------------------------------------------------------------------------
/obj/project.packagespec.json:
--------------------------------------------------------------------------------
1 | "restore":{"projectUniqueName":"E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj","projectName":"DesignPatternFactory","projectPath":"E:\\Repos\\Articles-master\\DesignPatterFactory\\DesignPatternFactory.csproj","outputPath":"E:\\Repos\\Articles-master\\DesignPatterFactory\\obj\\","projectStyle":"PackageReference","originalTargetFrameworks":["net6.0"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net6.0":{"targetAlias":"net6.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net6.0":{"targetAlias":"net6.0","imports":["net461","net462","net47","net471","net472","net48"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"}}
--------------------------------------------------------------------------------
/obj/rider.project.restore.info:
--------------------------------------------------------------------------------
1 | 16552307428473575
--------------------------------------------------------------------------------