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) { Shape[] Array = new Shape[100]; Array[0] = new Triangle(1, 1, Math.Sqrt(2)); Array[1] = new Rectangle(5, 6.5); Array[2] = new Circle(8); for (int i = 0; Array[i] != null; i++) Console.WriteLine(Array[i].calcArea()); Console.ReadLine(); }
static void Main() { Shape[] container = new Shape[3]; container[0] = new Triangle(2, 5); container[1] = new Rectangle(15, 2); container[2] = new Circle(15, 2); foreach (var shape in container) { shape.CalculateSurface(); } }
static void Main(string[] args) { Shape[] ArrayObject = new Shape[3]; Shape triangle = new Triangle(12, 12, 12); Shape circle = new Circle(12); Shape rectangle = new Rectangle(12, 12); ArrayObject[0] = triangle; ArrayObject[1] = circle; ArrayObject[2] = rectangle; for (int count = 0; count <= 2; count++) { Console.WriteLine(ArrayObject[count].Area()); } Console.ReadLine(); }
static void Main() { Rectangle rect2 = new Rectangle(21.5,10.3); Triangle tri2 = new Triangle(12.3, 15.4); Circle circ2 = new Circle(4.16); Rectangle rect1 = new Rectangle(10.4,5.3); Triangle tri1 = new Triangle(7.6,4.6); Circle circ1 = new Circle(1.5); List<Shape> shapes = new List<Shape>(); shapes.Add(rect2); shapes.Add(tri2); shapes.Add(circ2); shapes.Add(rect1); shapes.Add(tri1); shapes.Add(circ1); var orderedByAreas = shapes.OrderBy(s => s.CalculateSurface()); Print(orderedByAreas); }
public void ShouldThrowExceptionWhenPassedInvalidRadius() { var circle = new Circle(-2.2); }
public void ShouldReturnPerimeterWhenPassedValidRadius(double radius, double result) { var circle = new Circle(radius); Assert.That(circle.GetPerimeter(), Is.EqualTo(result)); }
public double ShouldReturnAreaValue(double radius) { var circle = new Circle(radius); return circle.GetArea(); }