uses System.SysUtils,
System.Generics.Collections;
type
TCar = class
end;
TSeller = class
public
Cars: TList<TCar>;
constructor Create;
procedure Sell;
end;
constructor TSeller.Create;
begin
Cars := TList<TCar>.Create;
end;
procedure TSeller.Sell;
begin
if Cars.Count = 0 then
raise Exception.Create(
'No cars for sale');
//some implementation...
end;
var
Seller: TSeller;
begin
Seller := TSeller.Create;
try
Seller.Sell;
except
on E: Exception do
WriteLn(E.Message);
//E.Message is 'No cars for sale'
end;
end.