Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ооп задачи.doc
Скачиваний:
1
Добавлен:
01.04.2025
Размер:
102.91 Кб
Скачать
  1. Cоздать текстовый редактор, позволяющий с помощью диалоговых окон сохранять и открывать текстовые файлы , а также изменять характеристики шрифта и цвет компонента Memo.

procedure TForm1.Button1Click(Sender: TObject);

begin

with openDialog1 do

begin

if not Execute then exit;

memo1.lines.loadFromFile(FileName)

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

with

saveDialog1 do

begin

if not Execute then exit;

memo1.lines.savetoFile(FileName)

end; end;

procedure TForm1.Button3Click(Sender: TObject);

begin

with fontDialog1 do

begin

if not Execute then exit;

memo1.font:=font;

end;

end;

procedure TForm1.Button4Click(Sender: TObject);

begin

close;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

memo1.Clear;

end;

end.

  1. ПОЛЯРНАЯ СИСТЕМА КООРДИНАТ R=5*SINFI

TForm1 = class(TForm)

Chart1: TChart;

Button1: TButton;

Series1: TPointSeries;

procedure Button1Click(Sender: TObject);

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var i:integer; x,y,v,r:array[1..420] of real;

begin

for i:=1 to 420 do

begin

v[i]:=(i-1)*0.0157;

r[i]:=5*sin(5*v[i]);

x[i]:=r[i]*cos(v[i]);

y[i]:=r[i]*sin(v[i]);

end;

for i:=1 to 420 do

chart1.Series[0].AddXY(x[i],y[i],'',clred);

end;

end.

  1. В chart y=sin(kx)

procedure TForm1.trckbr1Change(Sender: TObject);

var x,k:word;

begin

k:=trckbr1.Position;

Form1.Caption:=IntToStr(trckbr1.Position);

for x := 0 to 10 do

form1.series1.AddXY(x,Sin(k*x));

end;

  1. Типы линий

TForm1 = class(TForm)

implementation

{$R *.dfm}

procedure TForm1.FormPaint(Sender: TObject);

begin

//

with canvas do

begin

//сплошная

Pen.Style:=psSolid;

moveto(10,20);

lineto(200,20);

textout(250,10,'solid');

//тире

Pen.Style:=psDash;

moveto(10,40);

lineto(200,40);

textout(250,30,'dash');

//черточки

Pen.Style:=psDot;

moveto(10,60);

lineto(200,60);

textout(250,50,'dot');

//пунктир

Pen.Style:=psDashDot;

moveto(10,80);

lineto(200,80);

textout(250,70,'dashdot');

//смешанная

Pen.Style:=psDashDotDot;

moveto(10,100);

lineto(200,100);

textout(250,90,'dashdotdot')

end;

end;

end.

  1. Дерево-каталог в соответствии в соответствии с внутренним дисковым носителем

TForm1 = class(TForm)

DirectoryListBox1: TDirectoryListBox;

DriveComboBox1: TDriveComboBox;

BitBtn1: TBitBtn;

procedure DriveComboBox1Change(Sender: TObject);

implementation

{$R *.dfm}

procedure TForm1.DriveComboBox1Change(Sender: TObject);

begin

DirectoryListBox1.Drive:=DriveComboBox1.Drive;

end;

end.

  1. Выбор размера матрицы с помощью компонента combobox. Ввода значений элементов матрицы в stringgrid. Вычисление суммы четных элементов матрицы

TForm1 = class(TForm)

ComboBox1: TComboBox;

Button1: TButton;

Button2: TButton;

Label1: TLabel;

StringGrid1: TStringGrid;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var i,j:integer;

begin

case ComboBox1.ItemIndex of

0:begin for i:=0 to 4 do

for j:=0 to 4 do

StringGrid1.Cells[j,i]:=' ';

stringGrid1.RowCount:=3; StringGrid1.ColCount:=3; end;

1: begin for i:=0 to 4 do

for j:=0 to 4 do

StringGrid1.Cells[j,i]:=' ';

StringGrid1.RowCount:=4; StringGrid1.ColCount:=4; end;

2: begin for i:=0 to 4 do

for j:=0 to 4 do

StringGrid1.Cells[j,i]:=' ';

StringGrid1.RowCount:=5; StringGrid1.ColCount:=5; end;

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

var i,j,s:integer;

begin

s:=0;

if ComboBox1.ItemIndex=0 then begin

for j:=0 to 2 do

for i:=0 to 2 do

begin

label1.Visible:=true;

label1.Caption:=stringgrid1.Cells[j,i];

if strtoint(label1.Caption) mod 2=0 then

begin

label1.Visible:=true;

s:=s+strtoint(StringGrid1.Cells[j,i]);

label1.Caption:=inttostr(s);

end;

end;

end;

end;

if ComboBox1.ItemIndex=1 then begin

for j:=0 to 3 do

for i:=0 to 3 do

begin

label1.Visible:=true;

label1.Caption:=stringgrid1.Cells[j,i];

if strtoint(label1.Caption) mod 2=0 then

begin

label1.Visible:=true;

s:=s+strtoint(StringGrid1.Cells[j,i]);

label1.Caption:=inttostr(s);

end;

end;

end;

end;

end.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]