-- basically the same program – just formats output of values of type move
with Ada.Text_Io;
-- all statements in
with Ada.Integer_Text_Io; -- enables the reading and writing of
integers
procedure Inclassdemo4 is -- procedure body header
-- declarations go here
type Move is (Scissors, Paper, Rock);
package Move_Io is new Ada.Text_Io.Enumeration_Io (Move);
-- package integer_io is new ada.text_io.integer_io (integer);
-- statement above was
the old instantiation for integers
type Small_Int
is new Integer range 1 .. 10;
package Small_Int_Io is new Ada.Text_Io.Integer_Io
(Small_Int);
-- instantiation for small_int values
Computer_Move : Move;
User_Move : Move;
begin
loop
begin
Ada.Text_Io.Put (
" Please
enter a move for the user, it may be rock, paper or
scissors ");
Move_Io.Get
(User_Move);
Exception
when others =>
Ada.text_io.put_line (" you did not
enter an appropriate value ");
Ada.text_io.put (" Please
enter: rock, paper or scissors ");
end;
end loop;
Ada.Text_Io.Put
(
" Please enter a move for the computer, only
rock, paper or scissors ");
begin
Move_io.get (Computer_move);
exception
when others =>
Ada.text_io.put_line (" you did not enter
an appropriate value ");
Ada.text_io.put (" Please enter: rock, paper or scissors ");
Move_io.get
(Computer_Move);
end;
Ada.Text_Io.Put ( " Here is what the user entered ");
Move_Io.Put
(User_Move);
Ada.Text_Io.New_Line (1);
Ada.Text_Io.Put
(" here is what the computer's move is ");
Move_Io.Put
(Computer_Move);
ada.text_io.new_line(1);
for I in move'range loop
-- example of an attribute of enumerated type
move_Io.Put
(item =>I, width => 20);
end loop;
end Inclassdemo4;