|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
15.05.2012, 14:58 | #1 |
Новичок
Джуниор
Регистрация: 15.05.2012
Сообщений: 2
|
Классы в делфи
Помогите пожалуйста, мне нужно мою программу переделать так чтобы она решала с помощью отдельных классов,т. е. нужно из этой программы создать классы
вот текст unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, Math, XPMan; type Tmass=array of Real; Tmatrix=array of Tmass; TForm1 = class(TForm) Button2: TButton; Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Button3: TButton; Button4: TButton; Button5: TButton; StringGrid1: TStringGrid; Edit4: TEdit; Label2: TLabel; Label3: TLabel; Edit5: TEdit; Button6: TButton; Edit6: TEdit; Label4: TLabel; Button7: TButton; Button8: TButton; Edit7: TEdit; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Button9: TButton; Button10: TButton; Edit11: TEdit; Edit12: TEdit; Edit13: TEdit; Edit14: TEdit; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button10Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; i, j, Min, Max,n,m,t: Integer; implementation procedure TForm1.Button2Click(Sender: TObject); begin Randomize; For i:=0 To StringGrid1.RowCount-1 Do Begin For j:=0 To StringGrid1.ColCount-1 Do Begin StringGrid1.Cells[j,i]:=IntToStr(RandomRange(-50,50)); End; End; end; procedure TForm1.Button3Click(Sender: TObject); begin Edit1.Clear; Max := StrToInt(StringGrid1.Cells[0,0]); For i:=0 To StringGrid1.RowCount-1 Do Begin For j:=0 To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[i,j])>Max Then Max:=StrToInt(StringGrid1.Cells[i,j]); End; End; Edit1.Text := IntToStr(Max); end; procedure TForm1.Button4Click(Sender: TObject); begin Edit2.Clear; Min := StrToInt(StringGrid1.Cells[0,0]); For i:=0 To StringGrid1.RowCount-1 Do Begin For j:=0 To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[i,j])<Min Then Min:=StrToInt(StringGrid1.Cells[i,j]); End; End; Edit2.Text := IntToStr(Min); end; procedure TForm1.Button5Click(Sender: TObject); begin n:=StrToInt(Edit4.Text); For i:=0 To StringGrid1.RowCount-1 Do Begin For j:=0 To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[i,j])=n Then begin n:=StrToInt(StringGrid1.Cells[i,j]); m:=i; t:=j; end; End; End; Edit3.Text := IntToStr(t); Edit5.Text := IntToStr(m); end; procedure TForm1.Button6Click(Sender: TObject); begin n:=StrToInt(Edit6.Text); StringGrid1.ColCount:=n; StringGrid1.RowCount:=n; end; procedure TForm1.Button7Click(Sender: TObject); begin n:=StrToInt(Edit7.Text); Edit8.Clear; Max := StrToInt(StringGrid1.Cells[n,0]); For i:=n To StringGrid1.RowCount-1 Do Begin For j:=0 To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[n,j])>Max Then Max:=StrToInt(StringGrid1.Cells[n,j]); end; End; Edit8.Text := IntToStr(Max); end; procedure TForm1.Button9Click(Sender: TObject); begin n:=StrToInt(Edit11.Text); Edit12.Clear; Min := StrToInt(StringGrid1.Cells[n,0]); For i:=n To StringGrid1.RowCount-1 Do Begin For j:=0 To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[n,j])<Min Then Min:=StrToInt(StringGrid1.Cells[n,j]); End; End; Edit12.Text := IntToStr(Min); end; procedure TForm1.Button8Click(Sender: TObject); begin n:=StrToInt(Edit9.Text); Edit10.Clear; Max := StrToInt(StringGrid1.Cells[0,n]); For i:=0 To StringGrid1.RowCount-1 Do Begin For j:=n To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[i,n])>Max Then Max:=StrToInt(StringGrid1.Cells[i,n]); end; End; Edit10.Text := IntToStr(Max); end; procedure TForm1.Button10Click(Sender: TObject); begin n:=StrToInt(Edit13.Text); Edit14.Clear; Min := StrToInt(StringGrid1.Cells[0,n]); For i:=0 To StringGrid1.RowCount-1 Do Begin For j:=n To StringGrid1.ColCount-1 Do Begin If StrToInt(StringGrid1.Cells[i,n])<Min Then Min:=StrToInt(StringGrid1.Cells[i,n]); End; End; Edit14.Text := IntToStr(Min); end ; end. |
15.05.2012, 22:31 | #2 |
Пользователь
Регистрация: 04.06.2009
Сообщений: 22
|
Ну один класс у тебя уже есть - TForm1.
Все действия у тебя запихнуты в обработчики, которые являются методами класса TForm1. Так что - уже все готово! |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Классы в делфи | вася радугов | Помощь студентам | 14 | 05.09.2011 09:07 |
Классы в Делфи | Mg_Tasha | Помощь студентам | 3 | 17.10.2009 17:39 |
Задача в Делфи, классы. | Катерина_Ио | Фриланс | 3 | 18.05.2009 14:10 |