Exemple #1
0
 private bool CompareByWeightDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.Weight() < b.Weight())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
 private bool CompareByMaterialDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.MaterialType < b.MaterialType)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
 private bool CompareByVolumnDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.Volume() < b.Volume())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #4
0
 private bool CompareByShapeTypeDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.GeoType < b.GeoType)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #5
0
        private void btnAddShape_Click(object sender, EventArgs e)
        {
            Shape3D newShape = null;
            string  shape    = cboxShape.SelectedItem.ToString();

            try
            {
                newShape = ShapeFactory.Create(shape, _mType, Double.Parse(txtPara1.Text), Double.Parse(txtPara2.Text));
            }
            catch (FormatException ef)
            {
                MessageBox.Show(ef.Message);
            }
            catch (NegativeException en)
            {
                MessageBox.Show(en.Message);
            }
            finally
            {
                if (newShape != null)
                {
                    shapeArr.Add(newShape);
                    txtAmountOfShape.Text  = Shape3D.Amount.ToString();
                    txtBallAmount.Text     = Ball.Amount.ToString();
                    txtCubeAmount.Text     = Cube.Amount.ToString();
                    txtCylinderAmount.Text = Cylinder.Amount.ToString();
                    txtPyramidAmount.Text  = Pyramid.Amount.ToString();
                    ShowAllShapeInfo(txtMessage);
                }
            }
            //switch (shape)
            //{
            //    case "球":
            //        shapeArr.Add(new Ball(Double.Parse(txtPara1.Text), _mType));    // new 出 Ball 物件, 並將其加入 shapeArr中
            //        break;
            //    case "立方體":
            //        shapeArr.Add(new Cube(Double.Parse(txtPara1.Text), _mType));
            //        break;
            //    case "圓柱體":
            //        shapeArr.Add(new Cylinder(Double.Parse(txtPara1.Text), Double.Parse(txtPara2.Text), _mType));
            //        break;
            //    case "金字塔":
            //        shapeArr.Add(new Pyramid(Double.Parse(txtPara1.Text), Double.Parse(txtPara2.Text), _mType));
            //        break;
            //    default:
            //        break;
            //}
        }
Exemple #6
0
 private bool CompareByWeightD(Shape3D a, Shape3D b)
 {
     return(a.Weight() < b.Weight());
 }
Exemple #7
0
 private bool CompareByVolumnD(Shape3D a, Shape3D b)
 {
     return(a.Volume() < b.Volume());
 }
Exemple #8
0
 private bool CompareByMaterialD(Shape3D a, Shape3D b)
 {
     return(a.Material < b.Material);
 }
Exemple #9
0
 private bool CompareByGeoD(Shape3D a, Shape3D b)
 {
     return(a.Geo < b.Geo);
 }