private void btnResultRhomb_Click(object sender, EventArgs e) { Shape rhombus = new Rhombus(float.Parse(tbSideRhomb.Text)); lbPerymRhomb.Text = "Perimetr is " + rhombus.GetPerimeter(); lbAreaRhomb.Text = "Area is " + rhombus.GetArea(); }
static void Main() { Rhombus newRhombus = new Rhombus(3, 2); Console.WriteLine(newRhombus.CalculatePerimeter()); Console.WriteLine(newRhombus.CalculateArea()); Console.WriteLine(); //tuk zaradi nqkolkoto ctor-a mi dava da si izbiram dali da vuvejdam samo side // edno ili side1+2 ... Parallelogram newParallelogram = new Parallelogram(2, 4, 3); Console.WriteLine(newParallelogram.CalculateArea()); Console.WriteLine(newParallelogram.CalculatePerimeter()); Console.WriteLine(); Rectangle newRectangle = new Rectangle(2, 4); Console.WriteLine(newRectangle.CalculatePerimeter()); Console.WriteLine(newRectangle.CalculateArea()); Console.WriteLine(); Square newSquare = new Square(2); Console.WriteLine(newSquare.CalculatePerimeter()); Console.WriteLine(newSquare.CalculateArea()); }
public static void Main() { Rectangle rectangle = new Rectangle(5, 10); Rhombus rhobus = new Rhombus(5); Circle circle = new Circle(5); List<IShape> shapes = new List<IShape> { circle, rhobus, rectangle }; foreach (var figure in shapes) { Console.WriteLine(figure); } }
static void Main(string[] args) { Circle circle = new Circle(5); Rhombus rhombus = new Rhombus(5, 2); Rectangle rectangle = new Rectangle(2, 10); IShape[] shapes = { circle, rhombus, rectangle }; foreach (var shape in shapes) { Console.WriteLine("Area: {0}", shape.CalculateArea()); Console.WriteLine("Perimeter: {0}", shape.CalculatePerimeter()); } }
static void Main(string[] args) { Shape rect = new Rectangle(2.3, 3.2); Shape rhomb = new Rhombus(5.5, 4.5); Circle circle = new Circle(6.5); IShape[] arr = { rect, rhomb, circle }; foreach (IShape shape in arr) { Console.WriteLine(shape.GetType().Name); Console.WriteLine(shape.CalculateArea()); Console.WriteLine(shape.CalculatePerimeter()); Console.WriteLine(); } }
static void Main() { Circle circle = new Circle(5); Rectangle rectangle = new Rectangle(3, 2); Rhombus rhombus = new Rhombus(3, 2, 5); IShape[] shapes = new IShape[3] { circle, rectangle, rhombus }; foreach (var shape in shapes) { Console.WriteLine("{0}: Perimeter: {1}, Area: {2}", shape.GetType().Name, shape.CalculatePerimeter(), shape.CalculateArea()); } }
static void Main(string[] args) { Rhombus rhombus = new Rhombus(); rhombus._p1.X = 3; rhombus._p1.Y = 4; rhombus._p2.X = 12; rhombus._p2.Y = 4; rhombus._p3.X = 3; rhombus._p3.Y = 12; rhombus._p4.X = 12; rhombus._p4.Y = 12; rhombus.DisplayShape(); rhombus.move(Direction.Left, 2); rhombus.DisplayShape(ConsoleColor.Red); Console.ReadKey(); }