-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c16ddc4
commit eccbffe
Showing
76 changed files
with
1,991 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8C7AF5E6-E4FA-4883-89FB-3FD1AB074239}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>BuilderPattern</RootNamespace> | ||
<AssemblyName>BuilderPattern</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Lab1\Abstracts\BaseProductBuilder.cs" /> | ||
<Compile Include="Lab1\Concretes\ProductBuilder.cs" /> | ||
<Compile Include="Lab1\Delegate\ProductModel.cs" /> | ||
<Compile Include="Lab1\Directories\ProductDirectory.cs" /> | ||
<Compile Include="Lab2\Abstraction\CreditCartBuilder.cs" /> | ||
<Compile Include="Lab2\Concrete\AmerikanExpressCartBuilder.cs" /> | ||
<Compile Include="Lab2\Concrete\MasterCardBuilder.cs" /> | ||
<Compile Include="Lab2\Concrete\VisaCard.cs" /> | ||
<Compile Include="Lab2\Delegate\CreditCard.cs" /> | ||
<Compile Include="Lab2\Directories\CreditCardDirectory.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using BuilderPattern.Lab1.Delegate; | ||
|
||
namespace BuilderPattern.Lab1.Concretes | ||
{ | ||
public abstract class BaseProductBuilder | ||
{ | ||
public abstract void GetProductData(); | ||
public abstract void ApplyDiscount(); | ||
|
||
public abstract ProductModel GetModel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using BuilderPattern.Lab1.Delegate; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab1.Concretes | ||
{ | ||
public class ProductBuilder: BaseProductBuilder | ||
{ | ||
ProductModel model = new ProductModel(); | ||
|
||
public override void ApplyDiscount() | ||
{ | ||
model.DiscountPrice = model.UnitPrice * (decimal)0.90; | ||
model.DiscountedAppliyed = true; | ||
} | ||
|
||
public override ProductModel GetModel() => model; | ||
|
||
public override void GetProductData() | ||
{ | ||
model.Id = 1; | ||
model.ProductName = "Çinekop"; | ||
model.UnitPrice = 20; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab1.Delegate | ||
{ | ||
public class ProductModel | ||
{ | ||
public int Id { get; set; } | ||
public string ProductName { get; set; } | ||
public decimal UnitPrice { get; set; } | ||
public decimal DiscountPrice { get; set; } | ||
public bool DiscountedAppliyed { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
| ||
using BuilderPattern.Lab1.Concretes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab1.Directories | ||
{ | ||
public class ProductDirectory | ||
{ | ||
public void GenerateProduct(BaseProductBuilder productBuilder) | ||
{ | ||
productBuilder.GetProductData(); | ||
productBuilder.GetModel(); | ||
productBuilder.ApplyDiscount(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using BuilderPattern.Lab2.Delegate; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab2.Abstraction | ||
{ | ||
public abstract class CreditCartBuilder | ||
{ | ||
protected CreditCard card; | ||
|
||
public CreditCard Card { get => card; } | ||
|
||
public abstract void BankName(); | ||
public abstract void CardType(); | ||
public abstract void KartLimiti(); | ||
public abstract void TaksitleAlma(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
BuilderPattern/Lab2/Concrete/AmerikanExpressCartBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using BuilderPattern.Lab2.Abstraction; | ||
using BuilderPattern.Lab2.Delegate; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab2.Concrete | ||
{ | ||
class AmerikanExpressCartBuilder:CreditCartBuilder | ||
{ | ||
public AmerikanExpressCartBuilder() | ||
{ | ||
card = new CreditCard(); | ||
} | ||
|
||
public override void BankName() | ||
{ | ||
card.BankName = "Bank of America"; | ||
} | ||
|
||
public override void CardType() | ||
{ | ||
card.CardType = "American Express"; | ||
} | ||
|
||
public override void KartLimiti() | ||
{ | ||
card.CartLimit = 100000; | ||
} | ||
|
||
public override void TaksitleAlma() | ||
{ | ||
card.TaksitleAlma = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using BuilderPattern.Lab2.Abstraction; | ||
using BuilderPattern.Lab2.Delegate; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab2.Concrete | ||
{ | ||
public class MasterCardBuilder: CreditCartBuilder | ||
{ | ||
public MasterCardBuilder() | ||
{ | ||
card = new CreditCard(); | ||
} | ||
|
||
public override void BankName() | ||
{ | ||
card.BankName = "Türkiye İş Bankası"; | ||
} | ||
|
||
public override void CardType() | ||
{ | ||
card.CardType = "Master Card"; | ||
} | ||
|
||
public override void KartLimiti() | ||
{ | ||
card.CartLimit = 10000; | ||
} | ||
|
||
public override void TaksitleAlma() | ||
{ | ||
card.TaksitleAlma = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using BuilderPattern.Lab2.Abstraction; | ||
using BuilderPattern.Lab2.Delegate; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab2.Concrete | ||
{ | ||
public class VisaCard: CreditCartBuilder | ||
{ | ||
public VisaCard() | ||
{ | ||
card = new CreditCard(); | ||
} | ||
|
||
public override void BankName() | ||
{ | ||
card.BankName = "Garanti Bankası"; | ||
} | ||
|
||
public override void CardType() | ||
{ | ||
card.CardType = "Visa Card"; | ||
} | ||
|
||
public override void KartLimiti() | ||
{ | ||
card.CartLimit = 10000; | ||
} | ||
|
||
public override void TaksitleAlma() | ||
{ | ||
card.TaksitleAlma = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab2.Delegate | ||
{ | ||
public class CreditCard | ||
{ | ||
public string BankName { get; set; } | ||
public string CardType { get; set; } | ||
public int CartLimit { get; set; } | ||
public bool TaksitleAlma { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return $"{BankName} bankasına ait müşteri {CardType}'nı kullanmakta ve kartının {CartLimit} limitine sahiptir. Ayrıca taksit alma seçeneği ise: {TaksitleAlma}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using BuilderPattern.Lab2.Abstraction; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BuilderPattern.Lab2.Directories | ||
{ | ||
class CreditCardDirectory | ||
{ | ||
public void Constructor(CreditCartBuilder cartBuilder) | ||
{ | ||
cartBuilder.BankName(); | ||
cartBuilder.CardType(); | ||
cartBuilder.KartLimiti(); | ||
cartBuilder.TaksitleAlma(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using BuilderPattern.Lab1.Concretes; | ||
using BuilderPattern.Lab1.Directories; | ||
using BuilderPattern.Lab2.Abstraction; | ||
using BuilderPattern.Lab2.Concrete; | ||
using BuilderPattern.Lab2.Directories; | ||
using System; | ||
|
||
namespace BuilderPattern | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
#region Lab1 | ||
ProductDirectory productDirectory = new ProductDirectory(); | ||
ProductBuilder baseproductBuilder = new ProductBuilder(); | ||
|
||
productDirectory.GenerateProduct(baseproductBuilder); | ||
|
||
var model = baseproductBuilder.GetModel(); | ||
Console.WriteLine(model.Id); | ||
Console.WriteLine(model.ProductName); | ||
Console.WriteLine(model.UnitPrice); | ||
Console.WriteLine(model.DiscountPrice); | ||
Console.WriteLine(model.DiscountedAppliyed); | ||
#endregion | ||
|
||
#region Lab2 | ||
CreditCartBuilder gercekKart = new AmerikanExpressCartBuilder(); | ||
CreditCardDirectory kullan = new CreditCardDirectory(); | ||
kullan.Constructor(gercekKart); | ||
|
||
Console.WriteLine(gercekKart.Card.ToString()); | ||
#endregion | ||
|
||
Console.ReadKey(); | ||
} | ||
} | ||
} |
Oops, something went wrong.