-
Notifications
You must be signed in to change notification settings - Fork 0
/
aircraft.adb
64 lines (50 loc) · 1.56 KB
/
aircraft.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
with Ada.Numerics.discrete_Random;
package body Aircraft is
procedure Ascend(This : in out Aircraft_Type) is
begin
This.Is_In_The_Air := True;
end Ascend;
procedure Land(This : in out Aircraft_Type) is
begin
This.Is_In_The_Air := False;
end Land;
function Get_Is_In_The_Air(This : Aircraft_Type) return Boolean is
begin
return This.Is_In_The_Air;
end Get_Is_In_The_Air;
function Get_Coord(This : Aircraft_Type) return Coord is
begin
return This.Position;
end Get_Coord;
procedure Set_Card_Dir_Coord(This : in out Aircraft_Type; Card_Dir : in Cardinal_Direction) is
begin
Change_Direction(This.Position,Card_Dir);
end Set_Card_Dir_Coord;
procedure Start(This : in out Aircraft_Type) is
subtype Rand_Range is Integer range 0..100;
package Rand_Int is new Ada.Numerics.Discrete_Random(Rand_Range);
seed : Rand_Int.Generator;
begin
Rand_Int.Reset(seed);
Set_X(This.Position, Rand_Int.Random(seed));
Rand_Int.Reset(seed);
Set_Y(This.Position, Rand_Int.Random(seed));
null;
end Start;
function Get_Distance(This: Aircraft_Type; That : Aircraft_Type) return Integer is
begin
return Coords.Get_Distance(This.Position, That.Position);
end Get_Distance;
function Compare(Left, Right : Aircraft_Type) return Boolean is
begin
return (Left.Name < Right.Name);
end Compare;
procedure Action(This : in out Aircraft_Type) is
begin
Process(This.Name, This.Position, This.Is_In_The_Air);
end Action;
procedure Set_Coord(This : in out Aircraft_Type; Position : in Coord) is
begin
This.Position := Position;
end Set_Coord;
end Aircraft;