示例#1
0
 private bool CompareByWeightDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.Weight() < b.Weight())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 private bool CompareByMaterialDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.MaterialType < b.MaterialType)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
 private bool CompareByVolumnDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.Volume() < b.Volume())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#4
0
 private bool CompareByShapeTypeDescent(Shape3D a, Shape3D b)  //Ascent =true 時遞增 =false 時遞減
 {
     if (a.GeoType < b.GeoType)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#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;
            //}
        }
示例#6
0
 private bool CompareByWeightD(Shape3D a, Shape3D b)
 {
     return(a.Weight() < b.Weight());
 }
示例#7
0
 private bool CompareByVolumnD(Shape3D a, Shape3D b)
 {
     return(a.Volume() < b.Volume());
 }
示例#8
0
 private bool CompareByMaterialD(Shape3D a, Shape3D b)
 {
     return(a.Material < b.Material);
 }
示例#9
0
 private bool CompareByGeoD(Shape3D a, Shape3D b)
 {
     return(a.Geo < b.Geo);
 }