Example #1
0
 /// <summary>
 /// constructor that takes 3 parameters. Sets the baseShapes values and passes the value of the 
 /// shape's lenght to the base class's length field
 /// </summary>
 /// <param name="width">Input - width Parameter</param>
 /// <param name="height">Input - height Parameter</param>
 /// <param name="lenght">Input - lenght parameter</param>
 public Cylinder(double horRadius, double verRadius, double lenght)
     : base(lenght)
 {
     baseShape = new Ellipse(horRadius,verRadius);
     baseShape.ShapeType = Shapes.Cylinder;
 }
Example #2
0
        /// <summary>
        /// According to user selected values select and perform the operations
        /// according to the cases
        /// </summary>
        private void UpdateLables()
        {
            Shapes figure = GetFigure();
            Shape shape = null;

            switch (figure)
            {
                case Shapes.Rectangle:
                    {
                        //create instance of the Rectangle class and call necessary methods
                        //to perform operations
                        shape = new Rectangle(width,depth);
                        lblBaseArea.Text = ((Rectangle)shape).Area.ToString("0.00");
                        lblBaseCircum.Text = ((Rectangle)shape).Circum.ToString("0.00");

                        break;
                    }
                case Shapes.Circle:
                    {
                        //create instance of the Ellipse class and call necessary methods
                        //to perform operations
                        shape = new Ellipse(width);
                        lblBaseArea.Text = ((Ellipse)shape).Area.ToString("0.00");
                        lblBaseCircum.Text = ((Ellipse)shape).Circum.ToString("0.00");

                        break;
                    }
                case Shapes.Cylinder:
                    {

                        //create instance of the Cylinder class and call necessary methods
                        //to perform operations
                        shape = new Cylinder(width,depth,lenght);
                        lblBaseArea.Text = ((Cylinder)shape).BaseArea.ToString("0.00");
                        lblBaseCircum.Text = ((Cylinder)shape).BaseCircum.ToString("0.00");

                        lblVolume.Text = ((Cylinder)shape).Volume.ToString("0.00");
                        lblMantelArea.Text = ((Cylinder)shape).MantelArea.ToString("0.00");
                        lblTotSurfaceArea.Text = ((Cylinder)shape).TotalArea.ToString("0.00");

                        break;
                    }
                case Shapes.Ellipse:
                    {
                        //create instance of the Ellipse class and call necessary methods
                        //to perform operations
                        shape = new Ellipse(width,depth);
                        lblBaseArea.Text = ((Ellipse)shape).Area.ToString("0.00");
                        lblBaseCircum.Text = ((Ellipse)shape).Circum.ToString("0.00");

                        break;
                    }

                case Shapes.Prism:
                    {
                        //create instance of the Prism class and call necessary methods
                        //to perform operations
                        shape = new Prism(width, depth, lenght);
                        lblBaseArea.Text = ((Prism)shape).BaseArea.ToString("0.00");
                        lblBaseCircum.Text = ((Prism)shape).BaseCircum.ToString("0.00");

                        lblVolume.Text = ((Prism)shape).Volume.ToString("0.00");
                        lblMantelArea.Text = ((Prism)shape).MantelArea.ToString("0.00");
                        lblTotSurfaceArea.Text = ((Prism)shape).TotalArea.ToString("0.00");

                        break;
                    }

                case Shapes.Sphere:
                    {
                        //create instance of the Sphere class and call necessary methods
                        //to perform operations
                        shape = new Sphere(width);
                        lblBaseArea.Text = ((Sphere)shape).BaseArea.ToString("0.00");
                        lblBaseCircum.Text = ((Sphere)shape).BaseCircum.ToString("0.00");

                        lblVolume.Text = ((Sphere)shape).Volume.ToString("0.00");
                        lblMantelArea.Text = ((Sphere)shape).MantelArea.ToString("0.00");
                        lblTotSurfaceArea.Text = ((Sphere)shape).TotalArea.ToString("0.00");

                        break;
                    }

            }
        }
Example #3
0
 /// <summary>
 /// constructor that initilaizes the values
 /// </summary>
 /// <param name="radius"></param>
 public Sphere(double radius)
     : base(radius)
 {
     baseShape = new Ellipse(radius);
     baseShape.ShapeType = Shapes.Sphere;
 }
Example #4
0
        /// <summary>
        /// According to user selected values select and perform the operations
        /// according to the cases
        /// </summary>
        private void UpdateLables()
        {
            Shapes figure = GetFigure();
            Shape  shape  = null;

            switch (figure)
            {
            case Shapes.Rectangle:
            {
                //create instance of the Rectangle class and call necessary methods
                //to perform operations
                shape              = new Rectangle(width, depth);
                lblBaseArea.Text   = ((Rectangle)shape).Area.ToString("0.00");
                lblBaseCircum.Text = ((Rectangle)shape).Circum.ToString("0.00");

                break;
            }

            case Shapes.Circle:
            {
                //create instance of the Ellipse class and call necessary methods
                //to perform operations
                shape              = new Ellipse(width);
                lblBaseArea.Text   = ((Ellipse)shape).Area.ToString("0.00");
                lblBaseCircum.Text = ((Ellipse)shape).Circum.ToString("0.00");

                break;
            }

            case Shapes.Cylinder:
            {
                //create instance of the Cylinder class and call necessary methods
                //to perform operations
                shape              = new Cylinder(width, depth, lenght);
                lblBaseArea.Text   = ((Cylinder)shape).BaseArea.ToString("0.00");
                lblBaseCircum.Text = ((Cylinder)shape).BaseCircum.ToString("0.00");

                lblVolume.Text         = ((Cylinder)shape).Volume.ToString("0.00");
                lblMantelArea.Text     = ((Cylinder)shape).MantelArea.ToString("0.00");
                lblTotSurfaceArea.Text = ((Cylinder)shape).TotalArea.ToString("0.00");

                break;
            }

            case Shapes.Ellipse:
            {
                //create instance of the Ellipse class and call necessary methods
                //to perform operations
                shape              = new Ellipse(width, depth);
                lblBaseArea.Text   = ((Ellipse)shape).Area.ToString("0.00");
                lblBaseCircum.Text = ((Ellipse)shape).Circum.ToString("0.00");

                break;
            }

            case Shapes.Prism:
            {
                //create instance of the Prism class and call necessary methods
                //to perform operations
                shape              = new Prism(width, depth, lenght);
                lblBaseArea.Text   = ((Prism)shape).BaseArea.ToString("0.00");
                lblBaseCircum.Text = ((Prism)shape).BaseCircum.ToString("0.00");

                lblVolume.Text         = ((Prism)shape).Volume.ToString("0.00");
                lblMantelArea.Text     = ((Prism)shape).MantelArea.ToString("0.00");
                lblTotSurfaceArea.Text = ((Prism)shape).TotalArea.ToString("0.00");

                break;
            }

            case Shapes.Sphere:
            {
                //create instance of the Sphere class and call necessary methods
                //to perform operations
                shape              = new Sphere(width);
                lblBaseArea.Text   = ((Sphere)shape).BaseArea.ToString("0.00");
                lblBaseCircum.Text = ((Sphere)shape).BaseCircum.ToString("0.00");

                lblVolume.Text         = ((Sphere)shape).Volume.ToString("0.00");
                lblMantelArea.Text     = ((Sphere)shape).MantelArea.ToString("0.00");
                lblTotSurfaceArea.Text = ((Sphere)shape).TotalArea.ToString("0.00");

                break;
            }
            }
        }