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