pascalabcnet/TestSuite/CompilationSamples/Interf2.pas
Бондарев Иван e6e67c193c initial commit
2015-05-14 21:35:07 +02:00

49 lines
1 KiB
ObjectPascal

// Èíòåðôåéñû. Èíòåðôåéñ IComparer
uses System,System.Collections;
type
Student = class
private
name: string;
age,course,group: integer;
public
constructor (n: string; a,c,g: integer);
begin
name := n;
age := a;
course := c;
group := g;
end;
function ToString: string; override;
begin
Result := Format('Èìÿ: {0,9} Âîçðàñò: {1} Êóðñ: {2} Ãðóïïà: {3}',name,age,course,group);
end;
end;
procedure WriteArray<T>(prompt:string; a: array of T);
begin
writeln(prompt);
foreach x: T in a do
writeln(x);
writeln;
end;
function IsKozlov(s: Student): boolean;
begin
Result := s.name = 'Êîçëîâ'
end;
var a: array of Student;
begin
SetLength(a,5);
a[0] := new Student('Èâàíîâà',18,2,3);
a[1] := new Student('Êîçëîâ',19,3,10);
a[2] := new Student('Ñèäîðîâà',22,5,1);
a[3] := new Student('Êðèêóíîâ',17,1,2);
a[4] := new Student('Ëèõà÷åâ',25,4,8);
WriteArray('Èñõîäíûé ìàññèâ:',a);
writeln('Èíäåêñ Êîçëîâà = ',&Array.FindIndex(a,IsKozlov));
end.