Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Kompaniya_unit;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, Garaji_unit;
- const
- Garaj_Slot = 100;
- type
- TKompaniya = class
- private
- Mas: array[1..Garaj_Slot] of TGaraji;
- Mas_First, Mas_Last: integer;
- Mas_Count: integer;
- public
- constructor Create();
- function Add_Garaj(aGaraj_Info: TGaraji): boolean;
- function Del_Garaj: boolean;
- function Get_Garaz_Zanat_Slot: integer; {Выдает количество занятых мест}
- function Save(Save_File: string): boolean;
- function Load(Load_File: string): boolean;
- end;
- implementation
- constructor TKompaniya.Create();
- begin
- Mas_First := 1;
- Mas_Last := 1;
- Mas_Count := 0;
- end;
- function TKompaniya.Add_Garaj(aGaraj_Info: TGaraji): boolean;
- begin
- Result := False;
- if Mas_Count <> Garaj_Slot then
- begin
- Mas[Mas_Last] := aGaraj_Info;
- Mas_Last := Mas_Last + 1;
- Mas_Count := Mas_Count + 1;
- if Mas_Last > Garaj_Slot then
- Mas_Last := 1;
- Result := True;
- end;
- end;
- function TKompaniya.Del_Garaj: boolean;
- begin
- Result := False;
- if Mas_Count <> 0 then
- begin
- Mas[Mas_First] := nil;
- Mas_First := Mas_First + 1;
- if Mas_First > Garaj_Slot then
- Mas_First := 1;
- Mas_Count := Mas_Count - 1;
- Result := True;
- end;
- end;
- function TKompaniya.Get_Garaz_Zanat_Slot: integer;
- begin
- Result := Mas_Count;
- end;
- function TKompaniya.Save(Save_File: string): boolean;
- var
- i: integer;
- txt: file of TGaraji;
- begin
- AssignFile(txt, Save_File);
- rewrite(txt);
- Result := False;
- if Mas_Count <> 0 then
- begin
- for i := Mas_First to Mas_Last do
- Write(txt, Mas[i]);
- Close(txt);
- Result := True;
- end;
- end;
- function TKompaniya.Load(Load_File: string): boolean;
- var
- txt: file of TGaraji;
- begin
- Result := False;
- AssignFile(txt, Load_File);
- Reset(txt);
- Mas_Count := 0;
- while not EOF(txt) do
- begin
- Mas_Count := Mas_Count + 1;
- Read(txt, Mas[Mas_Count]);
- end;
- CloseFile(txt);
- Result := True;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement