Skip to content
Snippets Groups Projects
Program.cs 1003 B
Newer Older
using System;
using ATB_ChainPattern.BaseHandlers;
using ATB_ChainPattern.ConcreteHandlers;

namespace ATB_ChainPattern
{
    // Client Code
    class Program
    {
        static void Main(string[] args)
        {
AFONY10's avatar
AFONY10 committed
            string inputProduct, inputType = "";
            System.Console.WriteLine("Enter a product to analyze (Tesla Stock, Bitcoin): ");
            inputProduct = Console.ReadLine();

            System.Console.WriteLine("Enter the type of product (Stock, Crypto): ");
            inputType = Console.ReadLine();


            // Create handlers
            var stockHandler = new StockHandlerBase();
            var cryptoHandler = new CryptoHandlerBase();

            // Set up the chain
            stockHandler.SetSuccessor(cryptoHandler);

            // Client requests analysis of Tesla Stock
            stockHandler.AnalyzeProduct("Tesla Stock");

            // Client requests analysis of Bitcoin
            stockHandler.AnalyzeProduct("Bitcoin");
        }
    }
}