Fused | Ok! ben c'est bien comme ça alors
J'ai un petit exemple d'un programme de simulation d'un jeu de belote (rien de bien merveilleux qu'on nous avait demandé de faire).
Recopie le et execute le, ça peut te donner une idée du genre de trucs de base qu'on peut faire, désolé mais il est pas commenté, je pense que tu comprendra
C'est un pote qui l'a écrit.
Code :
- with Jewl.Simple_Windows;
- use Jewl.Simple_Windows;
- with Jewl.Io; use Jewl.Io;
- procedure Belotejwl is
-
- Bienvenue_Casse : Font_Type := Font("Time new Roman",16, True, False);
- version_casse : font_type := font("Comic sans MS", 8, false, true);
- Bienvenue : Dialog_Type := Dialog(230,200,"Bienvenue", 'B');
- Welcome : Label_type := Label(Bienvenue, (10,10), 200, 230, "Bienvenue dans le programme Belote", center, bienvenue_casse);
- Start : Button_Type := Button(Bienvenue, (10,100), 200, 60, "Commencer", 'S');
- Version : Label_Type := Label(Bienvenue, (10, 70), 200, 20, "Version 0.1 beta.", Center, Version_Casse);
-
- Ask_atout : Dialog_Type := Dialog(230,200,"Atout", 'A');
- Ask_atout_label : Label_type := Label(Ask_atout, (10,10), 200, 230, "Quel est l'atout de la partie ?", center);
- Valider : Button_Type := Button(Ask_atout, (10,100), 200, 60, "Valider", 'V');
- My_Frame : Frame_Type := Frame(230, 580, "Belote", 'Q');
-
- Carte1 : Label_type := Label(My_Frame, (10,10), 100, 400, "Carte 1" );
- Coul1 : Combobox_type := Combobox(My_Frame, (10,30), 200, false);
- Haut1 : Combobox_Type := Combobox(My_Frame, (10,60), 200, false);
-
- Carte2 : Label_type := Label(My_Frame, (10,100),100, 400, "Carte 2" );
- Coul2 : Combobox_type := Combobox(My_Frame, (10,120), 200, false);
- Haut2 : Combobox_Type := Combobox(My_Frame, (10,150), 200, False);
-
- Carte3 : Label_type := Label(My_Frame, (10,190), 100, 400, "Carte 3" );
- Coul3 : Combobox_type := Combobox(My_Frame, (10,210), 200, false);
- Haut3 : Combobox_Type := Combobox(My_Frame, (10,240), 200, False);
-
- Carte4 : Label_type := Label(My_Frame, (10,280), 100, 400, "Carte 4" );
- Coul4 : Combobox_type := Combobox(My_Frame, (10,300), 200, false);
- Haut4 : Combobox_Type := Combobox(My_Frame, (10,330), 200, False);
-
- Atout_label : Label_type := Label(My_Frame, (10,380), 100, 400, "Atout de la partie" );
- Atout : Combobox_type := Combobox(My_Frame, (10,400), 200, false);
-
- Calculer : Button_Type := Button(My_Frame, (10,440), 200, 100, "Calculer les points", 'C');
-
- Points : Integer;
-
- -- ------------------------------------------------- OK --
- function Ok return Boolean is
-
- Pas_Double : Boolean:=true;
-
- begin
- if (Get_Line(Coul1)=Get_Line(Coul2) and Get_Line(Haut1)=Get_Line(Haut2))
- or (Get_Line(Coul1)=Get_Line(Coul3) and Get_Line(Haut1)=Get_Line(Haut3))
- or (Get_Line(Coul1)=Get_Line(Coul4) and Get_Line(Haut1)=Get_Line(Haut4))
- or (Get_Line(Coul2)=Get_Line(Coul3) and Get_Line(Haut2)=Get_Line(Haut3))
- or (Get_Line(Coul2)=Get_Line(Coul4) and Get_Line(Haut2)=Get_Line(Haut4))
- or (Get_Line(Coul3)=Get_Line(Coul4) and Get_Line(Haut3)=Get_Line(Haut4))
- then pas_double:=false; end if;
- return Pas_double;
- end;
- -- -------------------------------------------------------
- -- ---------------------------------------------- REMPLI --
- function Rempli return Boolean is
-
- rempli : Boolean:=true;
-
- begin
- if Get_Line(Coul1)=0 or Get_Line(Coul2)=0 or Get_Line(Coul3)=0 or Get_Line(Coul4)=0
- or get_line(Haut1)=0 or get_line(Haut2)=0 or get_line(Haut3)=0 or get_line(Haut4)=0
- then rempli:=false;
- end if;
- return Rempli;
- end;
- -- -------------------------------------------------------
-
- -- -------------------------------------------- CALCULE --
- procedure Calcule is
-
- begin
- Points:=0;
-
- case Get_line(Haut1) is
- when 8 => points:=points+11;
- when 7 => points:=points+4;
- when 6 => points:=points+3;
- when 5 => if Get_line(coul1)=Get_line(Atout) then points:=points+20; else points:=points+2; end if;
- when 4 => points:=points+10;
- when 3 => if Get_line(Coul1)=Get_line(Atout) then points:=points+14; else points:=points+0; end if;
- when others => points:=points+0;
- end case;
-
- case Get_line(Haut2) is
- when 8 => points:=points+11;
- when 7 => points:=points+4;
- when 6 => points:=points+3;
- when 5 => if Get_line(coul2)=Get_line(Atout) then points:=points+20; else points:=points+2; end if;
- when 4 => points:=points+10;
- when 3 => if Get_line(Coul2)=Get_line(Atout) then points:=points+14; else points:=points+0; end if;
- when others => points:=points+0;
- end case;
-
- case Get_line(Haut3) is
- when 8 => points:=points+11;
- when 7 => points:=points+4;
- when 6 => points:=points+3;
- when 5 => if Get_line(coul3)=Get_line(Atout) then points:=points+20; else points:=points+2; end if;
- when 4 => points:=points+10;
- when 3 => if Get_line(Coul3)=Get_line(Atout) then points:=points+14; else points:=points+0; end if;
- when others => points:=points+0;
- end case;
-
- case Get_line(Haut4) is
- when 8 => points:=points+11;
- when 7 => points:=points+4;
- when 6 => points:=points+3;
- when 5 => if Get_line(coul4)=Get_line(Atout) then points:=points+20; else points:=points+2; end if;
- when 4 => points:=points+10;
- when 3 => if Get_line(Coul4)=Get_line(Atout) then points:=points+14; else points:=points+0; end if;
- when others => points:=points+0;
- end case;
-
- Message("Cette main vaut un total de " &Points &" points." );
- end;
- -- -------------------------------------------------------
- begin
-
- -- ---------------------------------------- INITIALISATIONS --
- Set_Text(Coul1, "Carreau" );
- Set_Text(Coul1, "Coeur" );
- Set_Text(Coul1, "Pique" );
- Set_Text(Coul1, "Trèfle" );
-
- Set_Text(Haut1, "7" );
- Set_Text(Haut1, "8" );
- Set_Text(Haut1, "9" );
- Set_Text(Haut1, "10" );
- Set_Text(Haut1, "Valet" );
- Set_Text(Haut1, "Dame" );
- Set_Text(Haut1, "Roi" );
- Set_Text(Haut1, "As" );
-
- Set_Text(Coul2, "Carreau" );
- Set_Text(Coul2, "Coeur" );
- Set_Text(Coul2, "Pique" );
- Set_Text(Coul2, "Trèfle" );
-
- Set_Text(Haut2, "7" );
- Set_Text(Haut2, "8" );
- Set_Text(Haut2, "9" );
- Set_Text(Haut2, "10" );
- Set_Text(Haut2, "Valet" );
- Set_Text(Haut2, "Dame" );
- Set_Text(Haut2, "Roi" );
- Set_Text(Haut2, "As" );
-
- Set_Text(Coul3, "Carreau" );
- Set_Text(Coul3, "Coeur" );
- Set_Text(Coul3, "Pique" );
- Set_Text(Coul3, "Trèfle" );
- Set_Text(Haut3, "7" );
- Set_Text(Haut3, "8" );
- Set_Text(Haut3, "9" );
- Set_Text(Haut3, "10" );
- Set_Text(Haut3, "Valet" );
- Set_Text(Haut3, "Dame" );
- Set_Text(Haut3, "Roi" );
- Set_Text(Haut3, "As" );
-
- Set_Text(Coul4, "Carreau" );
- Set_Text(Coul4, "Coeur" );
- Set_Text(Coul4, "Pique" );
- Set_Text(Coul4, "Trèfle" );
-
- Set_Text(Haut4, "7" );
- Set_Text(Haut4, "8" );
- Set_Text(Haut4, "9" );
- Set_Text(Haut4, "10" );
- Set_Text(Haut4, "Valet" );
- Set_Text(Haut4, "Dame" );
- Set_Text(Haut4, "Roi" );
- Set_Text(Haut4, "As" );
-
- Set_Text(Atout, "Carreau" );
- Set_Text(Atout, "Coeur" );
- Set_Text(Atout, "Pique" );
- Set_Text(Atout, "Trèfle" );
- -- --------------------------------------------------------- BIENVENUE --
- Show(Bienvenue, true);
- if next_command='S' then show(bienvenue, false); end if;
- -- ---------------------------------------------------------
-
-
- loop
- case Next_Command is
- when 'Q' => exit;
- when 'C' => if Ok then
- if Rempli then Calcule;
- else Error("Vous n'avez pas rempli tous les champs !" );
- end if;
- else Error("Vous avez rentré deux fois la même carte !" );
- end if;
- when others => null;
- end case;
- end loop;
- end;
|
|