Skip to content
Snippets Groups Projects
Commit f7637de6 authored by AFONY10's avatar AFONY10
Browse files

Opdated kode

parent 55d94135
No related branches found
No related tags found
No related merge requests found
using ATB_ChainPattern.BaseHandlers; using ATB_ChainPattern.DummyData;
using ATB_ChainPattern.DummyData;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -9,7 +8,7 @@ using System.Threading.Tasks; ...@@ -9,7 +8,7 @@ using System.Threading.Tasks;
namespace ATB_ChainPattern.ConcreteHandlers namespace ATB_ChainPattern.ConcreteHandlers
{ {
// Concrete handler for handling cryptocurrency analysis // Concrete handler for handling cryptocurrency analysis
class CryptoHandler : CurrencyHandlerBase // Should have inherited from CurrencyHandlerBase (diagram) class CryptoHandler : CurrencyHandler // Should have inherited from CurrencyHandlerBase (diagram)
{ {
protected override bool CanAnalyzeProduct(string productName, string productType) protected override bool CanAnalyzeProduct(string productName, string productType)
{ {
......
using ATB_ChainPattern.ConcreteHandlers; using ATB_ChainPattern.BaseHandlers;
using ATB_ChainPattern.DummyData; using ATB_ChainPattern.DummyData;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -6,10 +6,10 @@ using System.Linq; ...@@ -6,10 +6,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ATB_ChainPattern.BaseHandlers namespace ATB_ChainPattern.ConcreteHandlers
{ {
// Base class for handling currency-related products // Base class for handling currency-related products
public class CurrencyHandlerBase : ProductHandlerBase public class CurrencyHandler : ProductHandlerBase
{ {
// Common functionality for handling currency-related products // Common functionality for handling currency-related products
// This could include methods or properties specific to currencies // This could include methods or properties specific to currencies
...@@ -29,40 +29,40 @@ namespace ATB_ChainPattern.BaseHandlers ...@@ -29,40 +29,40 @@ namespace ATB_ChainPattern.BaseHandlers
protected override void Analyze(string productName, string productType) protected override void Analyze(string productName, string productType)
{ {
Console.WriteLine("CurrencyHandler: Analyzing " + productName + "..."); Console.WriteLine("CurrencyHandler: Analyzing " + productName + "...");
Thread.Sleep(3000); Thread.Sleep(3000);
if (productType == "Crypto") if (productType == "Crypto")
{ {
Console.WriteLine("Your product is of type Crypto currency! Let me redirect you to our Crypto specialist"); Console.WriteLine("Your product is of type Crypto currency! Let me redirect you to our Crypto specialist");
Thread.Sleep(3000); Thread.Sleep(3000);
IProductHandler handler = GetSuccessor(ProductType.Crypto); IProductHandler handler = GetSuccessor(ProductType.Crypto);
SetSuccessor(handler); SetSuccessor(handler);
successor.AnalyzeProduct(productName, productType); successor.AnalyzeProduct(productName, productType);
} }
else if (productType == "Forex") else if (productType == "Forex")
{ {
Console.WriteLine("Your product is of type Forex currency! Let me redirect you to our Forex specialist"); Console.WriteLine("Your product is of type Forex currency! Let me redirect you to our Forex specialist");
Thread.Sleep(3000); Thread.Sleep(3000);
IProductHandler handler = GetSuccessor(ProductType.Forex); IProductHandler handler = GetSuccessor(ProductType.Forex);
SetSuccessor(handler); SetSuccessor(handler);
successor.AnalyzeProduct(productName, productType); successor.AnalyzeProduct(productName, productType);
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Your product:" + productName + " is NOT worth buying!");
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Try look for the popular currencies");
}
} else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Your product:" + productName + " is NOT worth buying!");
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Try look for the popular currencies");
}
} }
private IProductHandler GetSuccessor(ProductType productType) private IProductHandler GetSuccessor(ProductType productType)
......
...@@ -65,7 +65,7 @@ namespace ATB_ChainPattern ...@@ -65,7 +65,7 @@ namespace ATB_ChainPattern
case ProductType.OtherCurrency: case ProductType.OtherCurrency:
case ProductType.Crypto: case ProductType.Crypto:
case ProductType.Forex: case ProductType.Forex:
return new CurrencyHandlerBase(); return new CurrencyHandler();
case ProductType.Commodity: case ProductType.Commodity:
return new CommodityHandler(); return new CommodityHandler();
......
...@@ -3,12 +3,11 @@ using System.Collections.Generic; ...@@ -3,12 +3,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ATB_ChainPattern.BaseHandlers;
using ATB_ChainPattern.DummyData; using ATB_ChainPattern.DummyData;
namespace ATB_ChainPattern.ConcreteHandlers namespace ATB_ChainPattern.ConcreteHandlers
{ {
class ForexHandler : CurrencyHandlerBase class ForexHandler : CurrencyHandler
{ {
protected override bool CanAnalyzeProduct(string productName, string productType) protected override bool CanAnalyzeProduct(string productName, string productType)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment