Wednesday 7 August 2024

Abstract factory pattern

 namespace ConsoleApp1

{

    public class TestCls

    {

        public delegate void DelGetMessage();

        public delegate void DelMethod(int x, int y);

        public delegate string MyDel(string str);

       public event MyDel myEvent;

        public  TestCls() {

            this.myEvent += new MyDel(WelComeUser);

        }

        public string WelComeUser(string user)

        {

            return "Welcome " + user;

        }

      


        public void GetValue()

        {

            Console.WriteLine("Test");

        }


        public string GetMsg()

        {

            DelGetMessage delGetMessage = new DelGetMessage(GetValue);

            delGetMessage.Invoke();

            return "Teststr";

        }


        public void plus_Method1(int x, int y)

        {

            Console.Write("You are in plus_Method");

            Console.WriteLine(x + y);

        }


        public void subtract_Method2(int x, int y)

        {

            Console.Write("You are in subtract_Method");

            Console.WriteLine(x - y);

        }



    }


    class Student

    {

        public int StudentID { get; set; }

        public String StudentName { get; set; }

        public int Age { get; set; }

    }

}



VehicleCompany vehicleCompany = new TataCompany();
vehicleCompany.Car();
VehicleCompany vehicleCompany2 = new TeslaCompany();
vehicleCompany.Bike();

No comments:

Post a Comment