/// <summary> /// Creates a shape of the specified Shape Type /// </summary> public static Shape CreateShape(ShapeType shapeType) { Console.Clear(); ViewHeader(shapeType.AsText()); double[] dimensions = ReadDimensions(shapeType); Console.WriteLine(); switch (shapeType) { case ShapeType.Circle: return new Ellipse(dimensions[0]); case ShapeType.Sphere: return new Sphere(dimensions[0] / 2); case ShapeType.Ellipse: return new Ellipse(dimensions[0], dimensions[1]); case ShapeType.Rectangle: return new Rectangle(dimensions[0], dimensions[1]); case ShapeType.Cuboid: return new Cuboid(dimensions[0], dimensions[1], dimensions[2]); case ShapeType.Cylinder: return new Cylinder(dimensions[0] / 2, dimensions[1] / 2, dimensions[2]); } return null; }
private static Shape CreateShape(ShapeType shapeType) { double[] ReturnArray; string shapeName = shapeType.AsText(); Console.BackgroundColor = ConsoleColor.DarkRed; Console.WriteLine(StringsFileR.FrameEqual); Console.WriteLine(shapeName.CenterAlignText(StringsViewMenu.EqualsFormat)); Console.WriteLine(StringsFileR.FrameEqual); Console.BackgroundColor = ConsoleColor.Black; ReturnArray = ReadDimensions(shapeType); if (shapeType == ShapeType.Circle) { return(new Ellipse(ReturnArray[0])); } else if (shapeType == ShapeType.Rectangle) { return(new Rectangle(ReturnArray[0], ReturnArray[1])); } else if (shapeType == ShapeType.Cuboid) { return(new Cuboid(ReturnArray[0], ReturnArray[1], ReturnArray[2])); } else if (shapeType == ShapeType.Cylinder) { return(new Cylinder(ReturnArray[0], ReturnArray[1], ReturnArray[2])); } else if (shapeType == ShapeType.Ellipse) { return(new Ellipse(ReturnArray[0], ReturnArray[1])); } return(new Sphere(ReturnArray[0])); }