uses wincrt;
var
player_turn :integer;
player :array[1..2] of string;
match_pile :array[1..5] of integer;
matches :integer;
pile_chosen :integer;
number_of_matches :integer;
total_matches :integer;
procedure C1_Input_turn_details;
begin
write('enter the pile number in which you wish to take from (1-5) ');
readln(pile_chosen);
write('enter the number of matches you wish to take (1-9) ');
readln(number_of_matches);
end;
procedure C2_Take_away_matches;
begin
match_pile[pile_chosen]:=match_pile[pile_chosen]-number_of_matches;
if total_matches = 0 then
A3_termination;
end;
procedure C3_Display_piles;
begin
writeln('pile 1 = ',match_pile[1]);
writeln('pile 2 = ',match_pile[2]);
writeln('pile 3 = ',match_pile[3]);
writeln('pile 4 = ',match_pile[4]);
writeln('pile 5 = ',match_pile[5]);
end;
procedure B1_One_turn;
begin
if player_turn = 1 then
player_turn := 2
else
player_turn := 1;
repeat
C3_display_piles;
C1_input_turn_details;
C2_Take_away_matches;
until (player_turn = 4);
end;
procedure A1_initialisation;
begin
write('enter the name of player 1.. ');
readln(player[1]);
clrscr;
write('enter the name of player 2.. ');
readln(player[2]);
clrscr;
randomize;
match_pile[1]:=random(8)+1;
match_pile[2]:=random(8)+1;
match_pile[3]:=random(8)+1;
match_pile[4]:=random(8)+1;
match_pile[5]:=random(8)+1;
total_matches:=match_pile[1]+match_pile[2]+match_pile[3]+match_pile[4]+match_pile[5];
player_turn:=2;
end;
procedure A2_main_body;
begin
B1_one_turn;
end;
procedure A3_termination;
begin
end;
begin
A1_initialisation;
A2_main_body;
A3_termination;
end.
Assignment for college and my Lecurer has neglected the section of how to use Procedures correectly, having a little triuble correctly creating the procedures any help apreciated, if yoiu need any more information just ask thanks.
- Gabriel
p.s Just need pointers on what I may be doing wrong thanks, code is not 100% complete as of yet such as the terminatiomn procedure