Скачиваний:
126
Добавлен:
08.05.2014
Размер:
5.68 Кб
Скачать
program laba;
uses crt,App,MsgBox,Objects,Menus,Drivers,Dialogs,Views;
const
cmCPU = 2000;
cmHDD = 2001;
ButtonsCPU : array[1..3] of string[10] = ('286','386 SX','486 SX');
ButtonsHDD : array[1..6] of string[10] =
('40 Mb','89 Mb','120 Mb','240 Mb','340 Mb','520 Mb');
type
TSpravka = object(TApplication)
WinCount: integer;
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function DialogCPU: PDialog; virtual;
function DialogHDD: PDialog; virtual;
end;
tpComputers=record
FirmName:string[10];
Processor:string[10];
hz:integer;
Memory:real;
HDD:integer;
Units:integer;
Monitor:string[10];
Cost:integer;
end;
var
vComputer : Array [1..15] of tpComputers;

{”ЋђЊ€ђЋ‚ЂЌ€… ќ‹…Њ…Ќ’Ћ‚ ‘’ђЋЉ€ ‘Ћ‘’ЋџЌ€џ}
procedure TSpravka.InitStatusLine;
var
R:TRect;
begin
GetExtent(R);
R.A.Y:=R.B.Y - 1;
New(StatusLine,Init(R,
NewStatusDef(0,$EFFF,
NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
NewStatusKey('~F10~ Menu', kbF10, cmMenu,
nil)),
nil)));
end;

{”ЋђЊ€ђЋ‚ЂЌ€… ќ‹…Њ…Ќ’Ћ‚ Њ…Ќћ}
procedure TSpravka.InitMenuBar;
var
R:TRect;
begin
GetExtent(R);
R.B.Y:=R.A.Y + 1;
MenuBar:= New(PMenuBar, Init(R, NewMenu(
NewItem('’ЁЇ ~–~Џ','F3',kbF3,cmCPU,hcNoContext,
NewItem('ЋЎкҐ¬ ~Ќ~†Њ„','F4',kbF4,cmHDD,hcNoContext,
nil)))));
end;

{‘Ћ‡„ЂЌ€… ‚›ЏЂ„Ђћ™…ѓЋ ЏЋ„Њ…Ќћ}
procedure TSpravka.HandleEvent(var Event: TEvent);
var
R:TRect;
Selection: Word;
i,errCode,q:integer;
hdd1:string[5];
begin
inherited HandleEvent(Event);
if Event.What <> evCommand then Exit;
if Event.Command = cmCPU then
begin
Selection:= 0;
if ExecuteDialog(DialogCPU, @Selection)<> cmOK then
begin
ClearEvent(Event);
exit;
end;
textcolor(LIGHTRED);
q:=0;
WINDOW(1,2,80,25);
CLRSCR;
GOTOXY(20,8);
WRITELN('ђ›ЌЋЉ HARDWARE (IBM PC) ‘ЂЌЉ’-Џ…’…ђЃ“ђѓЂ');
GOTOXY(9,10);
textcolor(LIGHTBLUE);
WRITELN('”Ёа¬  ’ЁЇ ѓж V-¬ V-¬ Љ®«-ў® Њ®­Ёв®а –Ґ­ ');
GOTOXY(9,11);
WRITELN(' –Џ –Џ Ћ‡“ Ќ†Њ„ ѓЊ„ ($)');
gotoxy(9,14+q);
window(9,14,75,19);
textcolor(LIGHTgreen);
for i:=1 to 10 do
begin
if Pos(ButtonsCPU[Selection+1],vComputer[i].Processor)>0 then
with vComputer[i] do begin
write(FirmName:10);
write(Processor:10);
write(hz);
write(Memory:6:1);
write(HDD:6);
write(Units:8);
write(Monitor:13);
writeLN(Cost:7);
q:=q+1;
end;
end;
ClearEvent(Event);
end;
if Event.Command = cmHDD then
begin
Selection:= 0;
if ExecuteDialog(DialogHDD, @Selection)<> cmOK then
begin
ClearEvent(Event);
exit;
end;
textcolor(LIGHTRED);
q:=0;
WINDOW(1,2,80,25);
CLRSCR;
GOTOXY(20,8);
WRITELN('ђ›ЌЋЉ HARDWARE (IBM PC) ‘ЂЌЉ’-Џ…’…ђЃ“ђѓЂ');
GOTOXY(9,10);
textcolor(LIGHTBLUE);
WRITELN('”Ёа¬  ’ЁЇ ѓж V-¬ V-¬ Љ®«-ў® Њ®­Ёв®а –Ґ­ ');
GOTOXY(9,11);
WRITELN(' –Џ –Џ Ћ‡“ Ќ†Њ„ ѓЊ„ ($)');
gotoxy(9,14+q);
window(9,14,75,19);
textcolor(LIGHTgreen);
for i:=1 to 10 do
begin
str(vComputer[i].HDD,HDD1);
if pos(hdd1,ButtonsHDD[Selection+1])>0 then
with vComputer[i] do begin
write(FirmName:10);
write(Processor:10);
write(hz);
write(Memory:6:1);
write(HDD:6);
write(Units:8);
write(Monitor:13);
writeLN(Cost:7);
q:=q+1;
end;
end;
ClearEvent(Event);
end;
end;

{ЋЏ€‘ЂЌ€… ќ‹-Ћ‚ ЏЋ„Њ…Ќћ}
function TSpravka.DialogCPU : PDialog;
var
R:TRect;
Dlg: PDialog;
B: PView;
begin
R.Assign(13,5,64,15);
New(Dlg, Init(R, '’ЁЇ CPU'));
with Dlg^ do begin
R.Assign(10,4,21,7);
B:= New(PRadioButtons,Init(R,
NewSItem('286',
NewSItem('386 SX',
NewSItem('486 SX',
nil)))));
Insert(B);
R.Assign(6,2,25,3);
Insert(New(PLabel,Init(R, '‚лЎҐаЁвҐ', B)));
R.Assign(33,5,43,7);
Insert(New(PButton, Init(R, '~O~K', cmOK, bfDefault)));
end;
SelectNext(False);
DialogCPU:= Dlg;
end;

function TSpravka.DialogHDD : PDialog;
var
R:TRect;
Dlg: PDialog;
B: PView;
begin
R.Assign(13,5,64,18);
New(Dlg, Init(R, '’ЁЇ HDD'));
with Dlg^ do begin
R.Assign(10,4,21,10);
B:= New(PRadioButtons,Init(R,
NewSItem('40 Mb',
NewSItem('89 Mb',
NewSItem('120 Mb',
NewSItem('240 Mb',
NewSItem('340 Mb',
NewSItem('520 Mb',
nil))))))));
Insert(B);
R.Assign(6,2,25,3);
Insert(New(PLabel,Init(R, '‚лЎҐаЁвҐ', B)));
R.Assign(33,5,43,7);
Insert(New(PButton, Init(R, '~O~K', cmOK, bfDefault)));
end;
SelectNext(False);
DialogHDD:= Dlg;
end;

{ Ћб­®ў­ п Џа®Ја ¬¬  }
var MyApp : TSpravka;
f : text;
n,i : integer;
begin
assign(f,'IBM_PC.DAT');
reset(f);

readln(f,n);
for i:=1 to n do
begin
with vComputer[i] do
begin
read(f,FirmName);
read(f,Processor);
read(f,hz);
read(f,Memory);
read(f,HDD);
read(f,Units);
read(f,Monitor);
readln(f,Cost);
end;
end;
MyApp.Init;
MyApp.Run;
MyApp.Done;
end.
Соседние файлы в папке VAR1