23-Mavzu: Chiziqli jadval elementlari yig‘indisini hisoblash loyihasi: StringGrid komponenti. StringGrid




Download 0.58 Mb.
bet5/5
Sana28.02.2024
Hajmi0.58 Mb.
#163623
1   2   3   4   5
Bog'liq
23-30
kurs ishi, test (1), Обратные задачи-макала, 301-000563, 99999999999999999999, moddiy texnika resurslari, ij5pbryAD9N0szc8s3qwn9xGGNxC496ER9Z3m9RH, 52659209065406, 1 savolga javob, 4-mustaqil ish biznes Nilufar, Egamberdiyeva Nodira Anvarovna. malaka ish slayd, Ornatilgan Tizinlar Fully, e-imzo taqdimot, 17159, ummatov-d
Mavzu: “Rasmli test” loyixasi.
Amaliy ish. Yangi oyna hosil qilamiz, Unga bitta PageControl, bitta BitBtn joylashtiramiz. So’ng Page Control oynasida sichqonchaning o’ng tugmasini bosib New Page buyrug’ini tanlaymiz. 3 ta Pge hosil qilamiz. 1-Pagega 1ta Memo joylaymiz, 2-Pagega 1 ta BitBtn, 1 taScrollBox va 2 ta label joylaymiz, 3-Pagega esa 1 ta Image va 2 ta Lbel obyektlarini joylaymiz. Obyektlarning xususiyatlarini rasmda ko’rsatilganday qilib o’zgartiramiz:

var
Form1: TForm1;


ball:integer;
type answers=array[1..5,0..3] of byte;
const otv:answers=((0,1,0,0),(0,1,0,0),(0,1,0,0),(0,0,0,1),(1,0,0,0));
implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
ball:=otv[1,radiogroup1.ItemIndex]+
otv[2,radiogroup2.ItemIndex]+
otv[3,radiogroup3.ItemIndex]+
otv[4,radiogroup4.ItemIndex]+
otv[5,radiogroup5.ItemIndex];
label3.Caption:='Togri javoblar soni:= ' +IntToStr(ball)+' --5 ta savoldan';
if ball=5 then label4.Caption:='Alo' else if (ball=3) or (ball=4) then label4.Caption:='yaxshi' else label4.Caption:='Qoniqarli'
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Form1.Close;
end;
end.
29-30-mavzu: Delphi tilida test dasturini yaratish texnologiyasi.
Biz Delphi dasturlash tilida tesdasturini yaratish uchun bizga test dasturi uchun bloknotda sovol tuzib olamiz bunda 1 fanning nomi 2 savollar soni misol uchun 5 ta savol uchun 5 raqam yoziladi 3 vaqt misol uchun 1 minut uchun 1:00 yoziladi savollar ketma-ketligi qatorma-qator yoziladi to’g’ri javobga 1,2,3,4 sonlar qo’yiladi agarda javoblar 4 tadan iborat bo’lsa, savoldan keying 1 qatordagi javob to’g’ri bo’lsa, 1 raqam qo’yiladi va ikkinchi savol boshlanadi va shu ketma-ketlik davom ettiriladi savolning javobini ixtiyoriy qatorga qo’yish mumkin. Rasm 1.

Rasm 1.
Delphida dasturi dizayni quyidagicha berilgan.

Rasm 2.
Fayl bo'limidan testni yuklaymiz rasm 3.

Rasm 3.
Dastur bajarilish dizayni rasm 4.

Rasm 4.
Dasturi kodi quyidagicha
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus, ExtCtrls;
type
// vaqt
TPrTime = Record
Min: Byte;
Sec: Byte;
end;
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N11: TMenuItem;
Panel1: TPanel;
Lbl_Last: TLabel;
Lbl_FQuestion: TLabel;
BtnV1: TButton;
BtnV2: TButton;
BtnV3: TButton;
BtnV4: TButton;
MQuestion: TMemo;
MIAbout: TMenuItem;
Timer1: TTimer;
MITest: TMenuItem;
MITBegin: TMenuItem;
MIOpenFile: TMenuItem;
Memo_Temp: TMemo;
MV1: TMemo;
MV2: TMemo;
MV3: TMemo;
MV4: TMemo;
OpenDialog1: TOpenDialog;
GBox: TGroupBox;
MIExit: TMenuItem;
MITEnd: TMenuItem;
LblNameTest: TLabel;
Label1: TLabel;
Label2: TLabel;
PanelButton: TPanel;
Label3: TLabel;
Lbl_NomQuestion: TLabel;
procedure FormCreate(Sender: TObject);
function DecTime(Var aa:TPrTime; Sender: TObject): string;
procedure PrTimeOut(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MIOpenFileClick(Sender: TObject);
procedure MIAboutClick(Sender: TObject);
procedure PrFillFileds(Sender: TObject);
procedure MITBeginClick(Sender: TObject);
procedure PrClickButton(Sender: TObject);
procedure MIExitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PrTimeLast: TPrTime;
PrTimeFull: TPrTime;
//nomer bo’yicha savol
NomQuestion: Byte;
// to’g’ri javoblar bali
PrVAnsverOK: Byte;
//nomer savol bo’yicha massiv
PrOrderQuestion: array [1..255] of byte;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
GBox.Visible:=False;
Timer1.Enabled:=False;
PrTimeLast.Min:=0;
PrTimeLast.Sec:=0;
MITBegin.Enabled:=True;
MITEnd.Enabled:=False;
NomQuestion:=1;
Memo_Temp.Lines.Clear;
PrVAnsverOK:=0;
PanelButton.Visible:=True;
end;
// --- Vaqt nazorati ---
Function PrFormatConvert(aa:TPrTime): String;
begin
if aa.Min<=9 then result:='0'+IntToStr(aa.Min)
else result:=IntToStr(aa.Min);
if aa.Sec<=9 then result:=result+':0'+IntToStr(aa.Sec)
else result:=result+':'+IntToStr(aa.Sec);
end;
// Vaqtni o’zgartiriash
function TForm1.DecTime(Var aa:TPrTime; Sender: TObject): string;
begin
if aa.Sec=0 then
if aa.Min>0 then
begin
dec(aa.Min);
aa.Sec:=59;
end
else PrTimeOut(Sender)
else dec(aa.Sec);
result:=PrFormatConvert(aa);
end;
// Vaqt bo’yicha savollarga javobni nazorat qilish
procedure TForm1.PrTimeOut(Sender: TObject);
begin
// Test variantlarini kiritish
if NomQuestion=StrToInt(copy(Memo_Temp.Lines[1],1,pos(' ',Memo_Temp.Lines[1])-1)) then
begin
Timer1.Enabled:=False;
PanelButton.Visible:=False; // Tugmachani tanlashni to’xtatish.
ShowMessage('Javob (Jami to`g`ri javob):'+#13+#10
+IntToStr(NomQuestion)+'\'+IntToStr(PrVAnsverOK)); //PrStatisticsTest(Sender);
Abort;
end;
{v0103} PrTimeLast.Min:=StrToInt(copy(Memo_Temp.Lines[1],
pos(' ',Memo_Temp.Lines[1])+1,pos(':',Memo_Temp.Lines[1])-pos(' ',Memo_Temp.Lines[1])-1)); {v0103} PrTimeLast.Sec:=StrToInt(copy(Memo_Temp.Lines[1],
pos(':',Memo_Temp.Lines[1])+1,Length(Memo_Temp.Lines[1])-pos(':',Memo_Temp.Lines[1]))); inc(NomQuestion);
PrFillFileds(Sender);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Lbl_Last.Caption:=DecTime(PrTimeLast,Sender);
end;
procedure TForm1.MIOpenFileClick(Sender: TObject);
begin
FormCreate(Sender);
OpenDialog1.InitialDir:=ExtractFilePath(Application.ExeName);
if OpenDialog1.Execute then
Memo_Temp.Lines.LoadFromFile(OpenDialog1.FileName);
end;
procedure TForm1.MIAboutClick(Sender: TObject);
begin
ShowMessage('Administrator: Tami;'+#13+#10+
' '+#13+#10+
'http:\\www.tami.uz'+#13+#10+#13+#10+
'e-mail: shoydullo@mail.ru; ');
end;
procedure TForm1.PrFillFileds(Sender: TObject);
begin
MQuestion.Clear;
MV1.Clear;
MV2.Clear;
MV3.Clear;
MV4.Clear;
MQuestion.Lines[0]:=Memo_Temp.Lines[2+6*(PrOrderQuestion[NomQuestion]-1)];
MV1.Lines[0]:=Memo_Temp.Lines[3+6*(PrOrderQuestion[NomQuestion]-1)];
MV2.Lines[0]:=Memo_Temp.Lines[4+6*(PrOrderQuestion[NomQuestion]-1)];
MV3.Lines[0]:=Memo_Temp.Lines[5+6*(PrOrderQuestion[NomQuestion]-1)];
MV4.Lines[0]:=Memo_Temp.Lines[6+6*(PrOrderQuestion[NomQuestion]-1)];
Lbl_NomQuestion.Caption:=IntToStr(NomQuestion);
if MQuestion.Lines.Count>=3 then MQuestion.scrollbars:=ssVertical else MQuestion.scrollbars:=ssNone;
if MV1.Lines.Count>=3 then MV1.scrollbars:=ssVertical else MV1.scrollbars:=ssNone;
if MV2.Lines.Count>=3 then MV2.scrollbars:=ssVertical else MV2.scrollbars:=ssNone;
if MV3.Lines.Count>=3 then MV3.scrollbars:=ssVertical else MV3.scrollbars:=ssNone;
if MV4.Lines.Count>=3 then MV4.scrollbars:=ssVertical else MV4.scrollbars:=ssNone;
end;
procedure TForm1.MITBeginClick(Sender: TObject);
Var
Stroka: String;
tempNomQuestion, i: byte;
begin
// Test faylni yuklash
if Memo_Temp.Lines.Count<4 then
begin
ShowMessage('Test faylini yuklang!');
Abort;
end;
Stroka:=Memo_Temp.Lines[1];
PrTimeLast.Min:=StrToInt(copy(Stroka,pos(' ',Stroka)+1,pos(':',Stroka)-pos(' ',Stroka)-1));
PrTimeLast.Sec:=StrToInt(copy(Stroka,pos(':',Stroka)+1,Length(Stroka)-pos(':',Stroka)));
PrTimeFull.Sec:=StrToInt(copy(Stroka,1,pos(' ',Stroka)-1))
*PrTimeLast.Sec mod 60;
PrTimeFull.Min:=StrToInt(copy(Stroka,1,pos(' ',Stroka)-1))
*PrTimeLast.Min + StrToInt(copy(Stroka,1,pos(' ',Stroka)-1))
*PrTimeLast.Sec div 60;
for i:=1 to 255 do
PrOrderQuestion[i]:=0;
tempNomQuestion:=0;
while tempNomQuestionbegin
randomize;
i:=1+random(StrToInt(copy(Memo_Temp.Lines[1],1,pos(' ',Memo_Temp.Lines[1])-1)));
if PrOrderQuestion[i]=0 then
begin
inc(tempNomQuestion);
PrOrderQuestion[i]:=tempNomQuestion;
end;
end;
PrFillFileds(Sender);
LblNameTest.Caption:=Memo_Temp.Lines[0];
Lbl_FQuestion.Caption:=PrFormatConvert(PrTimeFull);
Lbl_Last.Caption:=PrFormatConvert(PrTimeLast);
NomQuestion:=1;
MITBegin.Enabled:=False;
MITEnd.Enabled:=True;
GBox.Visible:=True;
PanelButton.Visible:=True;
Timer1.Enabled:=True;
end;
procedure TForm1.PrClickButton(Sender: TObject);
begin
if StrToInt(Memo_Temp.Lines[7+6*(NomQuestion-1)])=(Sender as TButton).Tag Then
begin
ShowMessage('To`g`ri');
inc(PrVAnsverOK);
end
else ShowMessage('Noto`g`ri');
PrTimeOut(Sender);
end;
procedure TForm1.MIExitClick(Sender: TObject);
begin
Close;
end;
end.
Download 0.58 Mb.
1   2   3   4   5




Download 0.58 Mb.

Bosh sahifa
Aloqalar

    Bosh sahifa



23-Mavzu: Chiziqli jadval elementlari yig‘indisini hisoblash loyihasi: StringGrid komponenti. StringGrid

Download 0.58 Mb.