public static void MockShape() { List <Shape> shapes = new(); Shape rectagle = new Rectagle(Color.Red, 200, 300), circle = new Circle(Color.Green, 3); shapes.Add(rectagle); shapes.Add(circle); shapes.ForEach(shape => Console.WriteLine(shape + " area: " + shape.Area())); }
public bool Run() { try { ////Circle Work this.Printer.Writeline("////////////Work with rectangles////////////"); Cirlce circle1 = new Cirlce(new Point(1, 1), new Point(2, 1)); this.Printer.Writeline($"cirlse ==> {circle1}"); Cirlce circle2 = new Cirlce(new Point(-1, 1), new Point(-1, 2)); this.Printer.Writeline($"Intersection of Two Circles {circle1} AND {circle2}"); foreach (Point point in circle1.Intersection(circle2)) { this.Printer.Writeline(point.ToString()); } circle1.Move(1, 3); this.Printer.Writeline($"cirlse after move(1,3) ==> {circle1}"); circle1.ChangeSize(new Point(-1, 1), new Point(-1, 5)); this.Printer.Writeline($"cirlse after changeSize(-1, 1),(-1, 5) ==> {circle1}"); this.Printer.Writeline($"Biggest between {circle1},{circle2} ===> {circle1.Biggest(circle2)}"); this.Printer.Writeline($"Least between {circle1},{circle2} ===> {circle1.Least(circle2)}"); ////Circle Work ////Rectangle Work this.Printer.Writeline("////////////Work with rectangles////////////"); Rectagle rectangle1 = new Rectagle(new Point(1, 1), new Point(2, -3)); this.Printer.Writeline($"rectangre ==> {rectangle1}"); Rectagle rectangle2 = new Rectagle(new Point(-1, 1), new Point(5, -3)); this.Printer.Writeline($"Intersection of Two Rectangles {rectangle1} AND {rectangle2} ==> {rectangle1.Intersection(rectangle2)}"); rectangle1.Move(1, 3); this.Printer.Writeline($"rectangle after move(1,3) ==> {rectangle1}"); rectangle1.ChangeSize(new Point(-1, 1), new Point(2, -2)); this.Printer.Writeline($"rectangle1 after changeSize(-1, 1),(-1, 5) ==> {rectangle1}"); this.Printer.Writeline($"Biggest between {rectangle1},{rectangle2} ===> {rectangle1.Biggest(rectangle2)}"); this.Printer.Writeline($"Least between {rectangle1},{rectangle2} ===> {rectangle1.Least(rectangle2)}"); ////Rectangle Work this.Printer.Writeline("////////////Work with Derictories////////////"); ShowerDirectory showerDirectory = new ShowerDirectory(); Stopwatch myTimer = new Stopwatch(); myTimer.Start(); showerDirectory.SymmetricalDifference(); showerDirectory.Intersection(); showerDirectory.ExpectDirectory(); WriterToConsole writerToConsole = new WriterToConsole(showerDirectory); WriterToExcel writerToExcel = new WriterToExcel(showerDirectory); //writerToConsole.SymmetricalDifference(); //writerToConsole.Intersection(); //writerToConsole.ExpectDirectory(); //writerToExcel.SymmetricalDifference(); //writerToExcel.Intersection(); //writerToExcel.ExpectDirectory(); myTimer.Stop(); this.Printer.Writeline($"time taken: {+myTimer.Elapsed}"); ListsComparer a = new ListsComparer(); a.CompareAndPrintUniqueValues(); //ExcelTest ecxel = new ExcelTest(); //ecxel.Write(); return(true); } catch (Exception e) { this.Printer.Writeline(e.Message); Console.ReadKey(); return(false); } }
static void Main(string[] args) { //SOLID Prensipleri=> Solid, beş önemli OOP prensiplerinin kısaltmasıdır. /* * Temiz, modüler ve genişletilebilir kod yazımında önemli kuralları tanımlar. * Aynı zamnda Agile yaızlım geliştirme için gereklidir. * * * SRP=> Single Responsibility Pricinple. * //Bir class sadece bir iş yapıyor olmalı. */ //Employee employee = new Employee(); //employee.ID = 1; //employee.FirstName = "Fatih"; //employee.LastName = "Günalp"; //employee.HireDate = new DateTime(2020, 02, 02); //BadEmployeeProcessor badEmployee = new BadEmployeeProcessor(); //badEmployee.InsertEmployee(employee); //Console.ReadKey(); //GoodEmployeeProcessor good = new GoodEmployeeProcessor(); //Console.WriteLine(good.InsertEmployee(employee) ? "Başarılır" : "Başarısız"); //Console.ReadKey(); //OCP=> Open/Closed Principle /* * Sınıflar ve metotlar genişletmeye açık değişikliğe kapalı olmalıdır. */ // BadCoffee badCoffee = new BadCoffee(); //decimal americano= badCoffee.GetTotalPrice(2, CoffeeType.Americano); // Console.WriteLine(americano.ToString()); // Console.ReadKey(); //GoodCoffee kahve1 = new Espresso(); //GoodCoffee kahve2 = new Americano(); //decimal price = 0; //price = kahve1.GetTotalPrice(5); //Console.WriteLine(price.ToString()); //Console.ReadKey(); //LSP=> Liskov's substution principle /* * Bir sınıftan türetilen sınıflar, base sınıfın yerine de kullanılabilmelidir. */ //BadReactangle reactangle = new BadReactangle(); //reactangle.Width = 2; //reactangle.Height = 3; //if (BadAreaCalculator.CalculateArea(reactangle) != 6) //{ // Console.WriteLine("Dörtgen alan hesaplamasında hatalı işlem"); //} //BadSquare square = new BadSquare(); //square.Height = 3; //if (BadAreaCalculator.CalculateArea(square) != 9) //{ // Console.WriteLine("Kare Alanı hesaplamasında hatalı işlem"); //} Rectagle rectagle = new Rectagle(); rectagle.Width = 2; rectagle.Height = 3; rectagle.Bildirim = "Dörtgen Oluşturuldu"; if (rectagle.RectangleArea() != 6) { Console.WriteLine("Dörtgen Alanı hesaplamasında hata var."); } Square square = new Square(); square.Width = 4; square.Bildirim = "Kare Oluşturuldu"; if (square.SquareArea() != 16) { Console.WriteLine("Kare Alanı hesaplamasında hata var."); } }