инфа_2лаб
.doc
МИНОБРНАУКИ РОССИИ
Санкт-Петербургский государственный
электротехнический университет
«ЛЭТИ» им. В.И. Ульянова (Ленина)
Кафедра биотехнических систем
отчет
по лабораторной работе 2
по дисциплине «Информатика»
Тема: Создание программы «Попадание точки в фигуру»
Студентка гр. 9502 |
|
Позняк В. Ю. |
Преподаватель |
|
Бельтюков М. В. |
Санкт-Петербург
2019
Цель работы.
Дана сложная фигура, вписанная в квадрат с координатами: левый нижний угол (5, 5), верхний правый угол (20, 20). Требуется написать программу для определения попадания точки с введенными координатами в указанную фигуру.
Код программы.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls,
Vcl.Samples.Spin;
type
TForm1 = class(TForm)
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Shape9: TShape;
BitBtn1: TBitBtn;
SECoordX: TSpinEdit;
SECoordY: TSpinEdit;
Shape10: TShape;
Label1: TLabel;
Label2: TLabel;
OK: TButton;
LResult: TLabel;
Shape11: TShape;
Label3: TLabel;
Label4: TLabel;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Shape15: TShape;
Shape16: TShape;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Shape17: TShape;
Shape18: TShape;
Shape19: TShape;
Shape20: TShape;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
SPoint: TShape;
procedure OKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OKClick(Sender: TObject);
begin
SPoint.Left := Shape6.Left - Shape6.Width + SECoordX.Value * (Shape6.Width div 5);
SPoint.Top := Shape6.Top + 2*Shape6.Height - SECoordY.Value * (Shape6.Height div 5);
if (((SECoordX.Value >=5) and (SECoordX.Value <=20) and
(SECoordY.Value >=5) and (SECoordY.Value <=20)) and
Not ((SECoordX.Value >=10) and (SECoordX.Value <15) and
(SECoordY.Value >=5) and (SECoordY.Value <15)))
then LResult.Caption :='ПОПАЛ'
else LResult.Caption :='МИМО';
end;
end.
Выводы.
При создании демонстрационной программы были получены навыки работы со следующими командами и визуальными компонентами: элементом фигуры Shape; элементом изменения значения цифр SpinEdit; связыванием событий объектов.