コード例 #1
0
 private void buttonCreateHeir_Click(object sender, EventArgs e)
 {
     try
     {
         GuessHeirForm g = new GuessHeirForm(FactoryTriangle.CreateObject(_tr1[0], _tr1[1], _tr1[2]), FactoryTriangle.CreateObject(_tr2[0], _tr2[1], _tr2[2]));
         //Hide();
         //Application.Run(new GuessHeirForm(FactoryTriangle.CreateObject(_tr1[0], _tr1[1], _tr1[2]), FactoryTriangle.CreateObject(_tr2[0], _tr2[1], _tr2[2])));
         g.ShowDialog();
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
ファイル: GuessHeirForm.cs プロジェクト: SergunWE/OOP_lab5-6
        public GuessHeirForm(ITriangle parent1, ITriangle parent2)
        {
            _trParent1       = parent1;
            _trParent2       = parent2;
            _1sidePrompts[0] = Math.Min(_trParent1.GetSide(1), _trParent2.GetSide(1));
            _1sidePrompts[1] = Math.Max(_trParent1.GetSide(1), _trParent2.GetSide(1));
            _2sidePrompts[0] = Math.Min(_trParent1.GetSide(2), _trParent2.GetSide(2));
            _2sidePrompts[1] = Math.Max(_trParent1.GetSide(2), _trParent2.GetSide(2));
            _anglePrompts[0] = Math.Min(_trParent1.GetAngle(), _trParent2.GetAngle());
            _anglePrompts[1] = Math.Max(_trParent1.GetAngle(), _trParent2.GetAngle());
            Random ran   = new Random();
            int    side1 = ran.Next((int)_1sidePrompts[0], (int)_1sidePrompts[1]);
            int    side2 = ran.Next((int)_2sidePrompts[0], (int)_2sidePrompts[1]);
            int    angle = ran.Next((int)_anglePrompts[0], (int)_anglePrompts[1]);

            _trHeir = FactoryTriangle.CreateObject(side1, side2, angle);
            InitializeComponent();
            _pTriangle[0] = _pFirst[0];
            _pTriangle[1] = _pFirst[0];
            _pTriangle[2] = _pFirst[1];
        }