الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طلب المساعدة في فهم و شرح الاجراء FillChar

بدأه dzdelphi2014 في 16 فبراير 2014 · 0 رد · 490 مشاهدة · في لغة Delphi
مشاركة: واتساب X فيسبوك تيليجرام
#1

 السلام عليكم

 

 اخواني الاعزاء نرجو منكم تقديم لي شرح وافي و مفصل حول الاجراء FILLCHAR     كنت ابحث عن سورس للعبة سؤال وجواب   فوجدت هذا السورس في احد المنتديات الفرنسية فلقيت اشكال في فهم الاجراء FILLCHAR    نرجو من الاخوة  شرح لي بالتفصيل ان امكن كود السورس التالي    للاشارة سورس العبة مرفق   وجزاكم الله خيرا

 

 

unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, StrUtils, ComCtrls, ExtCtrls;

type
  TElement = record
    Continent : string[8];
    Pays, Capitale: string[25];
  end;

Const
  nb = 97;
  Elements: array [0..nb-1] of TElement
   = (
        ( Continent : 'ASIE' ; Pays : 'AFGHANISTAN'; Capitale : 'KABOUL'),
        ( Continent : 'AFRIQUE' ; Pays : 'AFRIQUE DU SUD'; Capitale : 'PRETORIA'),
        ( Continent : 'EUROPE' ; Pays : 'ALBANIE'; Capitale : 'TIRANA'),
        ( Continent : 'AFRIQUE' ; Pays : 'ALGÉRIE'; Capitale : 'ALGER'),
        ( Continent : 'EUROPE' ; Pays : 'ALLEMAGNE'; Capitale : 'BERLIN'),
        ( Continent : 'AFRIQUE' ; Pays : 'ANGOLA'; Capitale : 'LUANDA'),
        ( Continent : 'ASIE' ; Pays : 'ARABIE SAOUDITE'; Capitale : 'RIYADH'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'ARGENTINE'; Capitale : 'BUENOS AIRES'),
        ( Continent : 'EUROPE' ; Pays : 'AUTRICHE'; Capitale : 'VIENNE'),
        ( Continent : 'EUROPE' ; Pays : 'BELGIQUE'; Capitale : 'BRUXELLES'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'BOLIVIE'; Capitale : 'LA PAZ'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'BRÉSIL'; Capitale : 'BRASILIA'),
        ( Continent : 'EUROPE' ; Pays : 'BULGARIE'; Capitale : 'SOFIA'),
        ( Continent : 'ASIE' ; Pays : 'CAMBODGE'; Capitale : 'PHNOM PENH'),
        ( Continent : 'AFRIQUE' ; Pays : 'CAMEROUN'; Capitale : 'YAOUNDE'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'CANADA'; Capitale : 'OTTAWA'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'CHILI'; Capitale : 'SANTIAGO'),
        ( Continent : 'ASIE' ; Pays : 'CHINE'; Capitale : 'PEKIN'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'COLOMBIE'; Capitale : 'BOGOTA'),
        ( Continent : 'ASIE' ; Pays : 'CORÉE DU NORD'; Capitale : 'PYONGYANG'),
        ( Continent : 'ASIE' ; Pays : 'CORÉE DU SUD'; Capitale : 'SEOUL'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'COSTA RICA'; Capitale : 'SAN JOSE'),
        ( Continent : 'AFRIQUE' ; Pays : 'CÔTE D''IVOIRE'; Capitale : 'YAMOUSSOUKRO'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'CUBA'; Capitale : 'LA HAVANE'),
        ( Continent : 'EUROPE' ; Pays : 'DANEMARK'; Capitale : 'COPENHAGUE'),
        ( Continent : 'AFRIQUE' ; Pays : 'ÉGYPTE'; Capitale : 'LE CAIRE'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'ÉQUATEUR'; Capitale : 'QUITO'),
        ( Continent : 'EUROPE' ; Pays : 'ESPAGNE'; Capitale : 'MADRID'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'ÉTATS-UNIS'; Capitale : 'WASHINGTON'),
        ( Continent : 'AFRIQUE' ; Pays : 'ÉTHIOPIE'; Capitale : 'ADDIS ABEBA'),
        ( Continent : 'EUROPE' ; Pays : 'FINLANDE'; Capitale : 'HELSINKI'),
        ( Continent : 'EUROPE' ; Pays : 'FRANCE'; Capitale : 'PARIS'),
        ( Continent : 'AFRIQUE' ; Pays : 'GABON'; Capitale : 'LIBREVILLE'),
        ( Continent : 'EUROPE' ; Pays : 'GRANDE-BRETAGNE'; Capitale : 'LONDRES'),
        ( Continent : 'EUROPE' ; Pays : 'GRÈCE'; Capitale : 'ATHÈNES'),
        ( Continent : 'AFRIQUE' ; Pays : 'GUINÉE'; Capitale : 'CONAKRY'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'HAÏTI'; Capitale : 'PORT-AU-PRINCE'),
        ( Continent : 'ASIE' ; Pays : 'HONG KONG'; Capitale : 'VICTORIA'),
        ( Continent : 'EUROPE' ; Pays : 'HONGRIE'; Capitale : 'BUDAPEST'),
        ( Continent : 'ASIE' ; Pays : 'INDE'; Capitale : 'NEW DELHI'),
        ( Continent : 'ASIE' ; Pays : 'INDONÉSIE'; Capitale : 'JAKARTA'),
        ( Continent : 'ASIE' ; Pays : 'IRAN'; Capitale : 'TÉHÉRAN'),
        ( Continent : 'ASIE' ; Pays : 'IRAQ'; Capitale : 'BAGDAD'),
        ( Continent : 'EUROPE' ; Pays : 'IRLANDE'; Capitale : 'DUBLIN'),
        ( Continent : 'EUROPE' ; Pays : 'ISLANDE'; Capitale : 'REYKJAVIK'),
        ( Continent : 'ASIE' ; Pays : 'ISRAËL'; Capitale : 'JÉRUSALEM'),
        ( Continent : 'EUROPE' ; Pays : 'ITALIE'; Capitale : 'ROME'),
        ( Continent : 'ASIE' ; Pays : 'JAPON'; Capitale : 'TOKYO'),
        ( Continent : 'ASIE' ; Pays : 'JORDANIE'; Capitale : 'AMMAN'),
        ( Continent : 'AFRIQUE' ; Pays : 'KENYA'; Capitale : 'NAÏROBI'),
        ( Continent : 'ASIE' ; Pays : 'KOWEÏT'; Capitale : 'KOWEÏT'),
        ( Continent : 'AFRIQUE' ; Pays : 'LESOTHO'; Capitale : 'MASERU'),
        ( Continent : 'ASIE' ; Pays : 'LIBAN'; Capitale : 'BEYROUTH'),
        ( Continent : 'AFRIQUE' ; Pays : 'LIBÉRIA'; Capitale : 'MONROVIA'),
        ( Continent : 'AFRIQUE' ; Pays : 'LIBYE'; Capitale : 'TRIPOLI'),
        ( Continent : 'EUROPE' ; Pays : 'LIECHTENSTEIN'; Capitale : 'VADUZ'),
        ( Continent : 'EUROPE' ; Pays : 'LUXEMBOURG'; Capitale : 'LUXEMBOURG'),
        ( Continent : 'AFRIQUE' ; Pays : 'MADAGASCAR'; Capitale : 'ANTANANARIVO'),
        ( Continent : 'ASIE' ; Pays : 'MALAISIE'; Capitale : 'KUALA-LUMPUR'),
        ( Continent : 'AFRIQUE' ; Pays : 'MALI'; Capitale : 'BAMAKO'),
        ( Continent : 'AFRIQUE' ; Pays : 'MAROC'; Capitale : 'RABAT'),
        ( Continent : 'AFRIQUE' ; Pays : 'MAURITANIE'; Capitale : 'NOUAKCHOTT'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'MEXIQUE'; Capitale : 'MEXICO'),
        ( Continent : 'EUROPE' ; Pays : 'MONACO'; Capitale : 'MONACO'),
        ( Continent : 'ASIE' ; Pays : 'MONGOLIE'; Capitale : 'OULAN-BATOR'),
        ( Continent : 'ASIE' ; Pays : 'MYANMAN (EX BIRMANIE)'; Capitale : 'RANGOON'),
        ( Continent : 'ASIE' ; Pays : 'NÉPAL'; Capitale : 'KATMANDOU'),
        ( Continent : 'AFRIQUE' ; Pays : 'NIGER'; Capitale : 'NIAMEY'),
        ( Continent : 'AFRIQUE' ; Pays : 'NIGÉRIA'; Capitale : 'ABUJA'),
        ( Continent : 'EUROPE' ; Pays : 'NORVÈGE'; Capitale : 'OSLO'),
        ( Continent : 'ASIE' ; Pays : 'NOUVELLE-CALÉDONIE'; Capitale : 'NOUMEA'),
        ( Continent : 'ASIE' ; Pays : 'PAKISTAN'; Capitale : 'ISLAMABAD'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'PANAMA'; Capitale : 'PANAMA'),
        ( Continent : 'EUROPE' ; Pays : 'PAYS-BAS'; Capitale : 'AMSTERDAM'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'PÉROU'; Capitale : 'LIMA'),
        ( Continent : 'ASIE' ; Pays : 'PHILIPPINES'; Capitale : 'MANILLE'),
        ( Continent : 'EUROPE' ; Pays : 'POLOGNE'; Capitale : 'VARSOVIE'),
        ( Continent : 'EUROPE' ; Pays : 'PORTUGAL'; Capitale : 'LISBONNE'),
        ( Continent : 'AFRIQUE' ; Pays : 'RÉPUBLIQUE CENTRAFRICAINE'; Capitale : 'BANGUI'),
        ( Continent : 'EUROPE' ; Pays : 'ROUMANIE'; Capitale : 'BUCAREST'),
        ( Continent : 'EUROPE' ; Pays : 'RUSSIE'; Capitale : 'MOSCOU'),
        ( Continent : 'AFRIQUE' ; Pays : 'SÉNÉGAL'; Capitale : 'DAKAR'),
        ( Continent : 'EUROPE' ; Pays : 'SLOVÉNIE'; Capitale : 'LJUBLJANA'),
        ( Continent : 'AFRIQUE' ; Pays : 'SOMALIE'; Capitale : 'MOGADISCIO'),
        ( Continent : 'AFRIQUE' ; Pays : 'SOUDAN'; Capitale : 'KHARTOUM'),
        ( Continent : 'EUROPE' ; Pays : 'SUÈDE'; Capitale : 'STOCKHOLM'),
        ( Continent : 'EUROPE' ; Pays : 'SUISSE'; Capitale : 'BERNE'),
        ( Continent : 'EUROPE' ; Pays : 'TCHÉCOSLOVAQUIE'; Capitale : 'PRAGUE'),
        ( Continent : 'ASIE' ; Pays : 'THAÏLANDE'; Capitale : 'BANGKOK'),
        ( Continent : 'AFRIQUE' ; Pays : 'TUNISIE'; Capitale : 'TUNIS'),
        ( Continent : 'ASIE' ; Pays : 'TURQUIE'; Capitale : 'ANKARA'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'URUGUAY'; Capitale : 'MONTEVIDEO'),
        ( Continent : 'AMÉRIQUE' ; Pays : 'VÉNÉZUELA'; Capitale : 'CARACAS'),
        ( Continent : 'ASIE' ; Pays : 'VIÊT NAM'; Capitale : 'HANOI'),
        ( Continent : 'ASIE' ; Pays : 'YÉMEN'; Capitale : 'SANAA'),
        ( Continent : 'AFRIQUE' ; Pays : 'ZAÏRE'; Capitale : 'KINSHASA'),
        ( Continent : 'AFRIQUE' ; Pays : 'ZAMBIE'; Capitale : 'LUSAKA')
   );

type
  TfMain = class(TForm)
    Panel2: TPanel;
    pCountry: TPanel;
    pReponse1: TPanel;
    pReponse2: TPanel;
    pReponse3: TPanel;
    pScore: TPanel;
    Label1: TLabel;
    pCorrection: TPanel;
    Label2: TLabel;
    Panel1: TPanel;
    lb: TListBox;
    procedure pReponseClick(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormActivate(Sender: TObject);
  private
    { Déclarations privées }
    iPays, Q, T : integer;
    Tires : array[0..99] of boolean;
  public
    { Déclarations publiques }
    procedure NouvellePartie;
    procedure QSuivante;
  end;

var
  fMain: TfMain;

implementation

uses uBulletin;

{$R *.dfm}

procedure TfMain.FormActivate(Sender: TObject);
begin
  NouvellePartie;
end;

procedure TfMain.NouvellePartie;
begin
  Randomize;
  Q:=0; T:=0;
  FillChar(Tires, SizeOf(Tires), #0);

  pCorrection.Caption:='';
  pScore.Caption:='';
  QSuivante
end;

// Proposer la question suivante

procedure TfMain.QSuivante;
var i: byte;
begin
  inc(T);
  fResultat.sg.Cells[0, T]:=format(' %2d', [T]);

  Label1.Caption:=format(' Question n° %d :', [T]);
  repeat
   iPays:= random(nb);
  until not Tires[iPays];
  Tires[iPays]:=true;
  fResultat.sg.Cells[1, T]:=' '+Elements[iPays].Pays;
  pCountry.Caption:=Elements[iPays].Pays;

  // Tirage 1° capitale
  repeat
   i:=random(nb);
  until (Elements.Continent = Elements[iPays].Continent)      // mm Continent
        and (Elements.Capitale <> Elements[iPays].Capitale);  // Capitale différente
  pReponse1.Tag:=i;
  pReponse1.Caption:=Elements.Capitale;

  // Tirage 2° capitale
  repeat
   i:=random(nb);
  until (Elements.Continent = Elements[iPays].Continent)      // mm Continent
        and (Elements.Capitale <> Elements[iPays].Capitale)   // Capitale différente
        and (pReponse1.Tag <> i);  // Capitale différente
  pReponse2.Tag:=i;
  pReponse2.Caption:=Elements.Capitale;

  // Tirage 3° capitale
  repeat
   i:=random(nb);
  until (Elements.Continent = Elements[iPays].Continent)      // mm Continent
        and (Elements.Capitale <> Elements[iPays].Capitale)  // Capitale différente
        and (pReponse1.Tag <> i)  // Capitale différente
        and (pReponse2.Tag <> i);
  pReponse3.Tag:=i;
  pReponse3.Caption:=Elements.Capitale;

//  for i:=1 to 100 do lb.Items.Add(InttoStr(Random(10)));
  i:=Random(10); lb.Items.Add(InttoStr(i));
  if i>7 then pReponse1.Caption:=Elements[iPays].Capitale
   else if i>3 then pReponse2.Caption:=Elements[iPays].Capitale
   else pReponse3.Caption:=Elements[iPays].Capitale;
end;


procedure TfMain.pReponseClick(Sender: TObject);
begin
  fResultat.sg.Cells[2, T]:=' '+TPanel(Sender).Caption;

  if TPanel(Sender).Caption = Elements[iPays].Capitale then
  begin
    inc(Q);
    fResultat.sg.Cells[3, T]:=' Correct';
    pCorrection.Caption:='Correct'
  end
  else
  begin
    pCorrection.Caption:='Faux !';
    fResultat.sg.Cells[3, T]:=' Faux !  => '+Elements[iPays].Capitale;
  end;

  pScore.Caption:=format('Votre score : %d / %d ', [Q, T]);

  if T<20 then QSuivante else
  begin
    fResultat.lScore.Caption:=pScore.Caption + '  -    Voulez-vous rejouer ?';
    if fResultat.ShowModal = mrYes
     then NouvellePartie
     else Application.Terminate
  end
end;

procedure TfMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
   if MessageDlg('Voulez-vous quitter ?', mtConfirmation, [mbYes, mbNo], 0) = mrNo
    then CanClose:=false
end;

end.
 

33911-1083795-quizz-des-capitales.zip

مواضيع مشابهة