Example #1
0
        public static Executor GetExecutorChain()
        {
            var junior = new JuniorDeveloper();
            var senior = new SeniorDeveloper();
            var lead   = new TeamLead();

            junior.SetNextExecutor(senior);
            senior.SetNextExecutor(lead);

            return(junior);
        }
Example #2
0
        static void Main(string[] args)
        {
            Candidate junior = new JuniorDeveloper();

            Console.WriteLine("Junior developer");
            junior.ApplyForJob();
            Console.WriteLine();

            Candidate senior = new SeniorDeveloper();

            Console.WriteLine("Senior developer");
            senior.ApplyForJob();
            Console.Read();
        }
Example #3
0
        private void CreateEmployee()
        {
            this.writer.Write("Enter employee type (Junior Developer, Junior Tester, Senior Developer): ");
            string type = reader.ReadLine().ToLower();

            if (type != "junior developer" && type != "junior tester" && type != "senior developer")
            {
                this.writer.WriteLine("Invalid type.");
                return;
            }

            this.writer.Write("Enter employee's name: ");
            string name = reader.ReadLine();

            this.writer.Write("Enter employee's personal number: ");
            string number = reader.ReadLine();

            if (this.company.Employees.ContainsKey(number))
            {
                this.writer.WriteLine("Employee with that personal number already works in the company.");
                return;
            }
            this.writer.Write("Enter employee's address: ");
            string address = reader.ReadLine();

            this.writer.Write("Enter employee's manager: ");
            string manager = reader.ReadLine();

            this.writer.Write("Enter date of employment (dd-mm-yyyy): ");
            int[] date = reader.ReadLine().Split('-').Select(int.Parse).ToArray();


            if (type == "junior developer")
            {
                this.writer.Write("Enter name of the project the employee's currently developing: ");
                string          project = reader.ReadLine();
                JuniorDeveloper junDev  = new JuniorDeveloper(name, number, address, new DateTime(date[2], date[1], date[0]), manager, project);
                this.AddEmployee(junDev);
                return;
            }

            if (type == "junior tester")
            {
                this.writer.Write("Enter name of the project the employee's currently testing: ");
                string project = reader.ReadLine();
                this.writer.Write("Enter name of the OS the employee's currently working with: ");
                string       os      = reader.ReadLine();
                JuniorTester junTest = new JuniorTester(name, number, address, new DateTime(date[2], date[1], date[0]), manager, project, os);
                this.AddEmployee(junTest);
                return;
            }

            if (type == "senior developer")
            {
                this.writer.Write("Enter name of the project the employee's currently developing: ");
                string projectDev = reader.ReadLine();
                this.writer.Write("Enter name of the project the employee's currently testing: ");
                string projectTest = reader.ReadLine();
                this.writer.Write("Enter name of the OS the employee's currently working with: ");
                string          os     = reader.ReadLine();
                SeniorDeveloper senDev = new SeniorDeveloper(name, number, address, new DateTime(date[2], date[1], date[0]), manager, projectDev, projectTest, os);
                this.AddEmployee(senDev);
                return;
            }
        }
Example #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            #region SRP

            Employee emp = new Employee();
            emp.FirstName = "Ali";
            emp.AddToDB(emp);

            _Employee emp1 = new _Employee();
            emp1.FirstName = "Deneme";

            EmployeeManager manager = new EmployeeManager(emp1);
            manager.Insert();

            EmployeeManager manager2 = new EmployeeManager(new MessageService(), emp1);
            manager2.SendMessage("Test");

            #endregion

            #region OCP

            OCPClient manager1 = new OCPClient(new NormalTicket());
            manager1.Sale(100);

            OCPClient manager3 = new OCPClient(new StudentTicket());
            manager3.Sale(100);

            #endregion

            #region LSP

            #region BadPractice

            Shape  s  = new Square(5, 10);
            double d1 = s.GetArea();

            Shape  s1 = new Rect(3, 5);
            double d2 = s1.GetArea();


            #endregion

            #region BestPractice


            AbstractShape s3 = new _Square(3);
            s3.GetArea();

            AbstractShape s4 = new _Rect(3, 5);
            s4.GetArea();

            AbstractShape s5 = new _Circle(5);

            MessageBox.Show(s5.Diagonal.ToString());


            #endregion

            #endregion

            //Interface Segregation Principle
            #region ISP

            #region BadPractice

            JuniorDeveloper j = new JuniorDeveloper();
            j.UseSolid();

            SeniorDeveloper ss = new SeniorDeveloper();
            ss.UseSolid();

            #endregion

            #region BestPractice

            JDeveloper j1 = new JDeveloper();
            j1.UseOOP();


            SDeveloper s3 = new SDeveloper();
            s3.UseOOP();
            s3.UseSolid();


            #endregion

            #endregion

            #region DIP

            #region BadPractice

            IOService service = new IOService(new DBIO());
            service.Write("asdasda", "asddsa");

            #endregion

            //read işlemleri için

            _IOService _service = new _IOService(new _ExcelIO());
            _service.Read("asdsad", "ssadasd");
            _service.Write("adsdas", "asdasd");

            _IOService _service2 = new _IOService(new _TextIO());
            _service2.Read("asdasd", "asdasd");
            _service2.Write("asdasd", "asdsad");

            _IOService _service3 = new _IOService(new _DBIO());
            _service3.Read("sadasd", "asdasd");



            #endregion
        }