Материал: Лабораторная работа №3

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

S_a=Chet(a)

S_b=Chet(b)

S_c=Chet(c)

Конец TriPloshadi2()

Входные параметры a,b,c

Выходные параметры S_a, S_b, S_c

Рисунок 4 – Блок-схема метода TriPloshadi2

Разработаем блок-схему метода double Chet(double ) и представим на рисунке 5.

Метод Chet()

Входные параметры L

Выходные параметры S

Начало Chet()

double S = (L * L) / (4 * Math.PI)

Return S

Конец Chet()

Рисунок 5 – Блок-схема метода Chet

Разработаем блок-схему событийного метода button1_Click и представим на рисунке 6.

Начало

L_a=ClassLibrary1.vscode.Vvod(textBox1)

L_b=ClassLibrary1.vscode.Vvod(textBox2)

L_c=ClassLibrary1.vscode.Vvod(textBox3)

ClassLibrary1.vscode.TriPloshadi(L_a, L_b, L_c, ref S_a, ref S_b, ref S_c)

ClassLibrary1.vscode.Vivod(textBox4, S_a)

ClassLibrary1.vscode.Vivod(textBox5, S_b)

ClassLibrary1.vscode.Vivod(textBox6, S_c)

Конец

Рисунок 6 – Блок-схема событийного метода с использованием параметра ref

Разработаем блок-схему событийного метода button3_Click и представим на рисунке 7.

Начало

L_a=ClassLibrary1.vscode.Vvod(textBox1)

L_b=ClassLibrary1.vscode.Vvod(textBox2)

L_c=ClassLibrary1.vscode.Vvod(textBox3)

ClassLibrary1.vscode.TriPloshadi(L_a, L_b, L_c, out S_a, out S_b, out S_c)

ClassLibrary1.vscode.Vivod(textBox4, S_a)

ClassLibrary1.vscode.Vivod(textBox5, S_b)

ClassLibrary1.vscode.Vivod(textBox6, S_c)

Конец

Рисунок 7 – Блок-схема событийного метода с использованием параметра out

8 Код программы

ClassLibrary1.dll

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace ClassLibrary1

{

public class vscode

{

public static double Vvod(TextBox t)

{

return Convert.ToDouble(t.Text);

}

public static void Vivod(TextBox t, double v)

{

t.Text = Convert.ToString(v);

}

public static double Chet(double L)

{

double S = (L * L) / (4 * Math.PI);

return S;

}

public static void TriPloshadi(double a, double b, double c, ref double S_a, ref double S_b, ref double S_c)

{

S_a = Chet(a);

S_b = Chet(b);

S_c = Chet(c);

}

public static void TriPloshadi2(double a, double b, double c, out double S_a, out double S_b, out double S_c)

{

S_a = Chet(a);

S_b = Chet(b);

S_c = Chet(c);

}

}

}

Form1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Второй_курс

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void label3_Click(object sender, EventArgs e)

{

}

private void label2_Click(object sender, EventArgs e)

{

}

private void label9_Click(object sender, EventArgs e)

{

}

private void label10_Click(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

Form2 f = new Form2();

this.Hide();

f.ShowDialog();

}

private void button2_Click(object sender, EventArgs e)

{

Form4 f = new Form4();

this.Hide();

f.ShowDialog();

}

private void button3_Click(object sender, EventArgs e)

{

Form6 f = new Form6();

this.Hide();

f.ShowDialog();

}

}

}

Form6.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Reflection;

using ClassLibrary1;

namespace Второй_курс

{

public partial class Form6 : Form

{

public Form6()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

double S_a=0, S_b=0, S_c= 0;

double L_a=0,L_b=0,L_c= 0;

L_a = ClassLibrary1.vscode.Vvod(textBox1);

L_b = ClassLibrary1.vscode.Vvod(textBox2);

L_c = ClassLibrary1.vscode.Vvod(textBox3);

ClassLibrary1.vscode.TriPloshadi(L_a, L_b, L_c, ref S_a, ref S_b, ref S_c);

ClassLibrary1.vscode.Vivod(textBox4, S_a);

ClassLibrary1.vscode.Vivod(textBox5, S_b);

ClassLibrary1.vscode.Vivod(textBox6, S_c);

}

private void button3_Click(object sender, EventArgs e)

{

double L_a, L_b, L_c, S_a, S_b, S_c;

L_a = ClassLibrary1.vscode.Vvod(textBox1);

L_b = ClassLibrary1.vscode.Vvod(textBox2);

L_c = ClassLibrary1.vscode.Vvod(textBox3);

ClassLibrary1.vscode.TriPloshadi2(L_a, L_b, L_c, out S_a, out S_b, out S_c);

ClassLibrary1.vscode.Vivod(textBox4, S_a);

ClassLibrary1.vscode.Vivod(textBox5, S_b);

ClassLibrary1.vscode.Vivod(textBox6, S_c);

}

private void button2_Click(object sender, EventArgs e)

{

Form1 f = new Form1();

this.Hide();

f.ShowDialog();

}

}

}

Источник: https://studfile.net/preview/16543852/