I'm very new to programming and have just gotten started with Records and boolean in Ada.
I'm trying to make it so that whenever I write 'T' it will say "True" and whenever I write 'F' it will say False, but I´m not sure how to do that. In this assignment I'm not allowed to change T: Boolean:= False;
this has to be in the code, but I´m not sure what I have to do to get what I want. I guess I have to do some sort of if statement like
But i´m not sure how to do that.
My code looks like the following:
type Sub_J is
record
Y: Character:= '9';
Q: Character:= 'p';
end record;
type Sub_B is
record
Y: Character:= 'J';
Q: Character:= 'o';
end record;
type Sub_O is
record
T: Boolean:= False;
L: Character:= '5';
end record;
type DS3 is
record
J: Sub_J;
B: Sub_B;
O: Sub_O;
end record;
procedure Get_3(DSThree: out DS3) is
Space: Character;
begin
Put("Mata in datamängd: ");
Get(DSThree.J.Y);
Get(Space);
Get(DSThree.J.Q);
Get(Space);
Get(DSThree.B.Y);
Get(Space);
Get(DSThree.B.Q);
Get(Space);
Get(DSThree.O.T);
Get(Space);
Get(DSThree.O.L);
end Get_3;
procedure Put_3(DSThree: in DS3) is
begin
Put("Inmatad datamängd: ");
Put(DSThree.J.Y);
Put(" ");
Put(DSThree.J.Q);
Put(" ");
Put(DSThree.B.Y);
Put(" ");
Put(DSThree.B.Q);
Put(" ");
Put(DSThree.O.T);
Put(" ");
Put(DSThree.O.L);
end Put_3;
I assume that you’re using Ada.Text_IO.Put
(or Put_Line
): what you have to do is to print the image of the variable.
In the case of a Character
or String
, the image is the thing itself. In the case of other simple types, you can apply the attribute Image
:
Ada.Text_IO.Put (T’Image);
This will result in TRUE
or FALSE
.