static void Main(string[] args) { //Toy a = new Toy(color: "blue", size: 15); //Toy b = new Toy(12, "pink"); //Toy c = new Toy(58, "green"); //List<Toy> toys = new List<Toy> { a, b, c }; //Person c1 = new Children(false); //Children c2 = new Children(false, toys); //Adults ad = new Adults(true); //List<Children> list = new List<Children>() { (Children)c1, c2 }; //Adults ad2 = new Adults(true, list); //Console.WriteLine(ad2.ToString()); //Console.WriteLine(c1.ToString()); //Console.WriteLine(c2.ToString()); // Console.WriteLine(a.ToString()); Point a = new Point(2, 2); Rectangle b = new Rectangle(3,2,a); Square d = new Square(2,a); Rectangle c = new Square(3,a); Ellipse e = new Ellipse(3, 2, a); Circle f = new Circle(3, a); Triangle t = new Triangle(3, 4, 5); Console.WriteLine(t.ToString()); Console.WriteLine(t.GetArea()); Console.WriteLine(t.GetPerimeter()); IMovable x = new Square(2,a); Console.WriteLine(x.ToString()); x.Move(3, 3); Console.WriteLine(x.ToString()); }
static void Main(string[] args) { int count = 0; List<ThreeDim> threeList = new List<ThreeDim>(); List<TwoDim> twoList = new List<TwoDim>(); int r; string shape1; while (true) { Console.Write("shpae (1.square,2.triangle,3.circle,4.sphere,5.cube) : "); shape1 = Console.ReadLine(); if (shape1 != "square" && shape1 != "triangle" && shape1 != "circle" && shape1 != "sphere" && shape1 != "cube") { shape1 = null; } try{ process(shape1); } catch(System.ArgumentNullException e) { Console.WriteLine("Enter square or triangle or circle or cube or sphere..please..", e); } try{ Console.Write("r : "); r = Int32.Parse(Console.ReadLine()); if (shape1 == "square") { foreach (var item in twoList) { if (item.type==1&&item.number==r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { TwoDim square = new Square(); Console.WriteLine("Two Dim"); Console.WriteLine("길이 : " + square.length(r)); Console.WriteLine("넓이 : " + square.Area(r)); twoList.Add(square); } count = 0; } else if (shape1 == "triangle") { foreach (var item in twoList) { if (item.type==2&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { TwoDim triangle = new triangle(); Console.WriteLine("Two Dim"); Console.WriteLine("길이 : " + triangle.length(r)); Console.WriteLine("넓이 : " + triangle.Area(r)); twoList.Add(triangle); } count = 0; } else if (shape1 == "circle") { foreach (var item in twoList) { if (item.type==3&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { TwoDim circle = new circle(); Console.WriteLine("Two Dim"); Console.WriteLine("길이 : " + circle.length(r)); Console.WriteLine("넓이 : " + circle.Area(r)); twoList.Add(circle); } count = 0; } else if (shape1 == "cube") { foreach (var item in threeList) { if (item.type==3&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { ThreeDim cube = new Cube(); Console.WriteLine("Three Dim"); Console.WriteLine("넓이 : " + cube.Area(r)); Console.WriteLine("부피 : " + cube.Volume(r)); threeList.Add(cube); } count = 0; } else if (shape1 == "sphere") { foreach (var item in threeList) { if (item.type==4&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { ThreeDim sphere = new Sphere(); Console.WriteLine("Three Dim"); Console.WriteLine("넓이 : " + sphere.Area(r)); Console.WriteLine("부피 : " + sphere.Volume(r)); threeList.Add(sphere); } count = 0; } } catch (System.FormatException e) { Console.WriteLine("Number..please..", e); } finally { } }//whlie문 }
static void Main(string[] args) { int count = 0; List<ThreeDim> threeList = new List<ThreeDim>(); List<TwoDim> twoList = new List<TwoDim>(); int r; string shape1; while (true) { Console.Write("shpae (1.square,2.triangle,3.circle,4.sphere,5.cube) : "); shape1 = Console.ReadLine(); Console.Write("r : "); r = Int32.Parse(Console.ReadLine()); if (shape1 == "square") { foreach (var item in twoList) { if (item.type==1&&item.number==r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { TwoDim square = new Square(); Console.WriteLine("Two Dim"); Console.WriteLine("길이 : " + square.length(r)); Console.WriteLine("넓이 : " + square.Area(r)); twoList.Add(square); } count = 0; } else if (shape1 == "triangle") { foreach (var item in twoList) { if (item.type==2&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { TwoDim triangle = new triangle(); Console.WriteLine("Two Dim"); Console.WriteLine("길이 : " + triangle.length(r)); Console.WriteLine("넓이 : " + triangle.Area(r)); twoList.Add(triangle); } count = 0; } else if (shape1 == "circle") { foreach (var item in twoList) { if (item.type==3&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { TwoDim circle = new circle(); Console.WriteLine("Two Dim"); Console.WriteLine("길이 : " + circle.length(r)); Console.WriteLine("넓이 : " + circle.Area(r)); twoList.Add(circle); } count = 0; } else if (shape1 == "cube") { foreach (var item in threeList) { if (item.type==3&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { ThreeDim cube = new Cube(); Console.WriteLine("Three Dim"); Console.WriteLine("넓이 : " + cube.Area(r)); Console.WriteLine("부피 : " + cube.Volume(r)); threeList.Add(cube); } count = 0; } else if (shape1 == "sphere") { foreach (var item in threeList) { if (item.type==4&&item.number == r) { Console.WriteLine("이미 존재 합니다.."); count = 1; break; } } if (count == 0) { ThreeDim sphere = new Sphere(); Console.WriteLine("Three Dim"); Console.WriteLine("넓이 : " + sphere.Area(r)); Console.WriteLine("부피 : " + sphere.Volume(r)); threeList.Add(sphere); } count = 0; } } }
public double ShouldReturnPermeter(double length) { var square = new Square(length); return square.GetPerimeter(); }
public void ShouldReturnAreaOfTheSquare(double length, double result) { var square = new Square(length); var actualresult = square.GetArea(); Assert.That(actualresult, Is.EqualTo(result)); }
public void ShouldNotHaveNegativeDimenson() { var square = new Square(-3.00); }