Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_IO; use Ada.Text_IO;
- with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
- with Ada.Numerics.Discrete_Random;
- -- --------------------------------------------
- procedure Rolldie is
- subtype One_To_Six is
- Integer range 1..6;
- -- --------------------------------------------
- package My_Random_Package is
- new Ada.Numerics.Discrete_Random(One_To_Six);
- use My_Random_Package;
- -- --------------------------------------------
- Procedure Topp(N: in Integer) is
- begin
- if (N = 5) or (N = 6) then
- PuT_line("|* * *|");
- elsif (N = 3) or (N = 4) then
- Put_Line("| * * |");
- elsif (N = 2) then
- Put_Line("| * |");
- else
- Put_Line("| |");
- end if;
- end Topp;
- -- -------------------------------------------
- Procedure bott(N: in Integer) is
- begin
- if (N = 6) then
- PuT_line("|* * *|");
- elsif (N = 5) or (N = 4) then
- Put_Line("| * * |");
- elsif (N = 3) or (N = 1) then
- Put_Line("| * |");
- else
- Put_Line("| * |");
- end if;
- end bott;
- -- -------------------------------------------
- procedure Skrivut(ggr : in Integer) is
- G : Generator;
- N : Integer;
- Summa : Integer := 0;
- begin
- Reset(G); -- Detta sätter slumptalsfröet som används för att
- -- ta fram de slumpade talen, skall göras EN gång
- -- per programkörning (varken mer eller mindre)
- for I in 1..ggr loop
- Put_line("+-----+");
- N := Random(G);
- Topp(N);
- Bott(N);
- Put_Line("+-----+");
- New_Line;
- Summa := Summa+N;
- end loop;
- Put("Summan blev: ");
- Put(Summa, Width => 0);
- end Skrivut;
- -- ------------------------------------------
- ggr : Integer;
- begin
- Put("Mata in antal slag: ");
- Get(Ggr);
- New_Line;
- Skrivut(Ggr);
- end Rolldie;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement