static void Main(string[] args) { GeometricFigure f1, f2, f3, f4, f5; f1 = new Circle(5); f2 = new Triangle(3, 4, 5); f3 = new Triangle(4, 5, 3); f4 = new Triangle(5, 3, 4); f5 = new Triangle(6, 7, 8); Console.WriteLine(f1.Area()); Console.WriteLine(f2.Area()); Console.WriteLine(f3.Area()); Console.WriteLine(f4.Area()); Console.WriteLine(f5.Area()); Console.ReadKey(); }
static void Main(string[] args) { Square square1 = new Square(); square1.SetSide(4); Console.WriteLine("square1 side = {0}", square1.GetSide()); Square square2 = new Square(); square2.SetSide(11); Console.WriteLine("square2 side = {0}", square2.GetSide()); Square square3 = new Square(6); Console.WriteLine("square3 side = {0}", square3.GetSide()); Triangle triangle1 = new Triangle(); Console.WriteLine("triangle1 area = {0}", triangle1.Area(7, 7)); Triangle triangle2 = new Triangle(); Console.WriteLine("triangle2 area = {0}", triangle2.Area(10, 10, 10)); int A = 1; int B = 2; int C = 0; Console.WriteLine("A = {0} B = {1} C = {2}", A, B, C); Set(A, ref B, out C); Console.WriteLine("A = {0} B = {1} C = {2}", A, B, C); Console.WriteLine(Min(new int[] { 6, 7, 9, 1, 2, 5, 6, 11 })); Console.WriteLine(Min(6, 7, 9, 1, 2, 5, 6, 11)); Console.WriteLine(); BetweenAandB(1, 10, new int[] { 7, 6, 9, 2, 0, 5, 8, 3, 4, 15, 34, 35 }); Console.ReadKey(); }
public static Shape GetShape(int type, Random random) { Shape shape; switch (type) { case 0: shape = new Rectangle(random.Next(1, 10), random.Next(1, 10)); break; case 1: shape = new Square(random.Next(1, 10)); break; default: shape = new Triangle(random.Next(1, 10), random.Next(1, 10)); break; } Console.WriteLine(shape.GetType().Name + ":" + shape.Area()); return(shape); }