Пример описания класса и подкласса (отрезок времени)

type TTime = class
  protected
    hour,min,sec: byte;
    function total_sec: integer;   // возвращает полное число секунд
    procedure timefromsec(tsec: integer);  // перевод сек. в ч.м.с
  public
    procedure settime(h,m,s: byte);
 // присваивание полям, исправление аргументов
    procedure print; // вывод значений полей
    procedure plus(first,second: ttime);
    procedure minus(first,second: ttime);
    procedure mult(first: ttime; second:byte);
    procedure divide(first: ttime; second:byte);
end;
function TTime.total_sec: integer; begin
    total_sec := hour*3600 + min*60 + sec;
end;
procedure TTime.timefromsec(tsec: integer); begin
    hour := tsec div 3600;
    min := tsec mod 3600 div 60;
    sec := tsec mod 3600 mod 60;
end;
procedure TTime.settime(h,m,s: byte); begin
    hour:=h; min:=m; sec:=s;
    if sec > 59 then begin
      min := min + sec div 60;
      sec := sec mod 60;
    end;
    if min > 59 then begin
      hour := hour + min div 60;
      min := min mod 60;
    end;
end;
procedure TTime.print; begin
    writeln(hour,':',min,':',sec);
end;
procedure TTime.plus(first,second: ttime); begin
    timefromsec(first.total_sec + second.total_sec);
end;
procedure TTime.minus(first,second: ttime); begin
    if first.total_sec > second.total_sec then
        timefromsec(first.total_sec - second.total_sec);
end;
procedure TTime.mult(first: ttime; second:byte); begin
    timefromsec(first.total_sec * second);
end;
procedure TTime.divide(first: ttime; second:byte); begin
    if second <> 0 then
       timefromsec(first.total_sec div second);
end;
 
type TLTime = class(TTime)
  protected
    days: byte;
    function total_sec: integer;
    procedure timefromsec(tsec: integer);
  public
    procedure settime(d,h,m,s: byte);
    procedure print;
end;
 
function TLTime.total_sec: integer; begin
    total_sec := days*24*3600 + hour*3600 + min*60 + sec;
end;
procedure TLTime.timefromsec(tsec: integer);
var time: integer;
begin
    days := tsec div (24*3600);
    time := tsec mod (24*3600);
    inherited timefromsec(time);
end;
procedure TLTime.settime(d,h,m,s: byte); begin
    inherited settime(h,m,s);
    days := d;
    if hour > 23 then begin
      days := days + hour div 24;
      hour := hour mod 24
    end;
end;
procedure TLTime.print; begin
      writeln(days,' days; ',hour,':',min,':',sec);
end;
 
var a,b,c: TTime;
  aa,bb: TLTime;
begin
    begin
        a := TTime.Create;
        b := TTime.Create;
        c := TTime.Create;
        a.settime(4,30,0);
        b.settime(12,55,70);
        a.print;
        b.print;
        c.plus(a,b);
        c.print;
        c.minus(b,a);
        c.print;
        c.mult(a,3);
        c.print;
        c.divide(a,2);
        c.print;
        writeln;
    end;
    aa := TLTime.Create;
    bb := TLTime.Create;
    aa.settime(5,34,12,35);
    bb.settime(12,20,0,0);
    aa.print;
    bb.print;
readln;
end.