private void buttonRandom_Click(object sender, RoutedEventArgs e) { Drob[] drobs = new Drob[4]; for (int i = 0; i < 4; i++) { Random random = new Random(); drobs[i] = new Drob(random.Next(1, (i + 3) * 4), random.Next(1, (i + 1) * 5)); Drob.Down(drobs[i]); } textBoxFirstNum.Text = drobs[0].Num.ToString(); textBoxFirstDenom.Text = drobs[0].Denom.ToString(); textBoxSecondNum.Text = drobs[1].Num.ToString(); textBoxSecondDenom.Text = drobs[1].Denom.ToString(); textBoxThirdNum.Text = drobs[2].Num.ToString(); textBoxThirdDenom.Text = drobs[2].Denom.ToString(); textBoxFourthNum.Text = drobs[3].Num.ToString(); textBoxFourthDenom.Text = drobs[3].Denom.ToString(); labelResultFirst.FontSize = 16; labelResultFirst.Text = "Дробь№1\n" + drobs[0].ToString(); labelResultSecond.FontSize = 16; labelResultSecond.Text = "Дробь№2\n" + drobs[1].ToString(); labelResultThird.FontSize = 16; labelResultThird.Text = "Дробь№3\n" + drobs[2].ToString(); labelResultFourth.FontSize = 16; labelResultFourth.Text = "Дробь№4\n" + drobs[3].ToString(); }
private void result2_Click(object sender, RoutedEventArgs e) { try { Drob drob1 = new Drob(double.Parse(textBoxFirstNum.Text), double.Parse(textBoxFirstDenom.Text)); Drob drob2 = new Drob(double.Parse(textBoxSecondNum.Text), double.Parse(textBoxSecondDenom.Text)); Drob drob3 = new Drob(double.Parse(textBoxThirdNum.Text), double.Parse(textBoxThirdDenom.Text)); Drob drob4 = new Drob(double.Parse(textBoxFourthNum.Text), double.Parse(textBoxFourthDenom.Text)); Drob result = (drob4 + drob2) / (drob1 - drob3); textBlockResul.Text = Drob.Down(result).ToString(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }