Lig (Puan Durumu)

DrogbA

Forum Üyesi
Katılım
27 Ara 2020
Mesajlar
3,440
Tepkime puanı
0
Puanları
36
Öncelikli olarak Takım Gir kısmından lige kaç adet takım girilecekse eklenmelidir.Takım ekleme işlemi bittikten sonra eklenmiş listeden bir takım seçilip Skor Gir butonuna tıklanır. İki takım arasındaki maçın skoru girilir. Buna istinaden oluşan puan durumu anında yansıtılır.

unit1.cpp

Kod:
//---------------------------------------------------------------------------
 
#include <vcl.h>
#pragma hdrstop
 
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int kontrol=0;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(Edit1->Text!="")
{
ListBox1->Items->Add(Edit1->Text);
Edit1->Text="";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
 
if(kontrol==0)
{
for(int i=0;i<ListBox1->Items->Count;i++)
{
ListBox2->Items->Add("0");
ListBox3->Items->Add("0");
}
kontrol=1;
}
int x=ListBox1->ItemIndex;
if(x<0)
Application->MessageBox(L"1.Takımı Seçiniz",L"UYARI",MB_ICONINFORMATION) ;
else
{
 Form2->ListBox1->Items->Clear();
 Form2->Show();
 for(int p=0;p<ListBox1->Items->Count;p++)
 {
 if(p!=x)
 Form2->ListBox1->Items->Add(ListBox1->Items->Strings[p]);
 }
 Label1->Visible=false;
Edit1->Visible=false;
Button1->Visible=false;
}
}
 
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, wchar_t &Key)
{
if(Key==L'Ð' || Key==L'ğ')
Key=L'Ð';
else if(Key==L'Ü' || Key==L'ü')
Key=L'Ü';
else if(Key==L'ş' || Key==L'ş')
Key=L'ş';
else if(Key==L'İ' || Key==L'i')
Key=L'İ';
else if(Key==L'Ö' || Key==L'ö')
Key=L'Ö';
else if(Key==L'ş' || Key==L'ş')
Key=L'ş';
else if(Key==L'Ç' || Key==L'ç')
Key=L'Ç';
else if((UpCase(Key)<L'A'|| UpCase(Key)>L'Z')&& Key!=VK_DELETE && Key!=VK_BACK )
Key=0;
}
//---------------------------------------------------------------------------

unit2.cpp

Kod:
//---------------------------------------------------------------------------
 
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
int x=ListBox1->ItemIndex;
if(x<0)
Application->MessageBox(L"2.Takımı Seçiniz",L"UYARI",MB_ICONINFORMATION) ;
else
{
 String yazdir=Form1->ListBox1->Items->Strings[Form1->ListBox1->ItemIndex]+" ile "+Form2->ListBox1->Items->Strings[Form2->ListBox1->ItemIndex]+" Arasındaki Oynanan Maçın Skorunu Giriniz";
 String skor=InputBox(L"SKOR GİR",yazdir.t_str(),"0-0");
 char dizi[3];
 strcpy(dizi,skor.t_str());
 int skor1=StrToInt(dizi[0]);
 int skor2=StrToInt(dizi[2]);
 int averaj;
 
 int sira1=Form1->ListBox1->ItemIndex;
 int sira2;
 int puan;
 
 for(int z=0;z<Form1->ListBox1->Items->Count;z++)
 {
     if(Form2->ListBox1->Items->Strings[Form2->ListBox1->ItemIndex]==Form1->ListBox1->Items->Strings[z])
     sira2=z;
 }
 
 if(skor1>skor2)
 {
   puan=StrToInt(Form1->ListBox2->Items->Strings[sira1]);
   puan+=3;
   Form1->ListBox2->Items->Strings[sira1]=IntToStr(puan);
   averaj=StrToInt(Form1->ListBox3->Items->Strings[sira1]);
   averaj+=(skor1-skor2);
   Form1->ListBox3->Items->Strings[sira1]=IntToStr(averaj);
   averaj=StrToInt(Form1->ListBox3->Items->Strings[sira2]);
   averaj-=(skor1-skor2);
   Form1->ListBox3->Items->Strings[sira2]=IntToStr(averaj);
 }
 if(skor2>skor1)
 {
 
   puan=StrToInt(Form1->ListBox2->Items->Strings[sira2]);
   puan+=3;
   Form1->ListBox2->Items->Strings[sira2]=IntToStr(puan);
   averaj=StrToInt(Form1->ListBox3->Items->Strings[sira2]);
   averaj+=(skor2-skor1);
   Form1->ListBox3->Items->Strings[sira2]=IntToStr(averaj);
   averaj=StrToInt(Form1->ListBox3->Items->Strings[sira1]);
   averaj-=(skor2-skor1);
   Form1->ListBox3->Items->Strings[sira1]=IntToStr(averaj);
 }
 if(skor1==skor2)
 {
   puan=StrToInt(Form1->ListBox2->Items->Strings[sira1]);
   puan+=1;
   Form1->ListBox2->Items->Strings[sira1]=IntToStr(puan);
   puan=StrToInt(Form1->ListBox2->Items->Strings[sira2]);
   puan+=1;
   Form1->ListBox2->Items->Strings[sira2]=IntToStr(puan);
 }
 
 
 
}
Form1->ListBox4->Items->Clear();
Form1->ListBox5->Items->Clear();
Form1->ListBox6->Items->Clear();
Form1->ListBox7->Items->Clear();
Form1->ListBox8->Items->Clear();
Form1->ListBox9->Items->Clear();
 
for(int l=0;l<Form1->ListBox1->Items->Count;l++)
Form1->ListBox7->Items->Add(Form1->ListBox1->Items->Strings[l]);
for(int l=0;l<Form1->ListBox2->Items->Count;l++)
Form1->ListBox5->Items->Add(Form1->ListBox2->Items->Strings[l]);
for(int l=0;l<Form1->ListBox3->Items->Count;l++)
Form1->ListBox6->Items->Add(Form1->ListBox3->Items->Strings[l]);
 
for(int p=0;p<Form1->ListBox2->Items->Count;p++)
{
    for(int k=p+1;k<Form1->ListBox5->Items->Count;k++)
    {
        if(StrToInt(Form1->ListBox5->Items->Strings[p])<StrToInt(Form1->ListBox5->Items->Strings[k]))
        {
            String temp=Form1->ListBox5->Items->Strings[p];
            Form1->ListBox5->Items->Strings[p]=Form1->ListBox5->Items->Strings[k];
            Form1->ListBox5->Items->Strings[k]=temp;
            String temp2=Form1->ListBox6->Items->Strings[p];
            Form1->ListBox6->Items->Strings[p]=Form1->ListBox6->Items->Strings[k];
            Form1->ListBox6->Items->Strings[k]=temp2;
            String temp3=Form1->ListBox7->Items->Strings[p];
            Form1->ListBox7->Items->Strings[p]=Form1->ListBox7->Items->Strings[k];
            Form1->ListBox7->Items->Strings[k]=temp3;
        }
    }
}
 
for(int p=0;p<Form1->ListBox5->Items->Count;p++)
{
    for(int k=p+1;k<Form1->ListBox5->Items->Count;k++)
    {
       if(Form1->ListBox5->Items->Strings[p]==Form1->ListBox5->Items->Strings[k])
       {
           if(StrToInt(Form1->ListBox6->Items->Strings[p])<StrToInt(Form1->ListBox6->Items->Strings[k]))
           {
            String temp=Form1->ListBox6->Items->Strings[p];
            Form1->ListBox6->Items->Strings[p]=Form1->ListBox6->Items->Strings[k];
            Form1->ListBox6->Items->Strings[k]=temp;
            String temp1=Form1->ListBox7->Items->Strings[p];
            Form1->ListBox7->Items->Strings[p]=Form1->ListBox7->Items->Strings[k];
            Form1->ListBox7->Items->Strings[k]=temp1;
           }
       }
 
    }
}
 
for(int i=0;i<Form1->ListBox1->Items->Count;i++)
{
 
  String yazdir=Form1->ListBox7->Items->Strings[i];
  Form1->ListBox4->Items->Add(yazdir) ;
  yazdir=Form1->ListBox5->Items->Strings[i];
  Form1->ListBox8->Items->Add(yazdir) ;
  yazdir=Form1->ListBox6->Items->Strings[i];
  Form1->ListBox9->Items->Add(yazdir) ;
 
}
 
 Form2->Close();
 Form1->Show();
}
//---------------------------------------------------------------------------
 

Nutella

Bayan Üye
Özel Üye
Katılım
2 Ocak 2021
Mesajlar
3,559
Tepkime puanı
0
Puanları
36
Cinsiyet
  1. Bayan
Takım
Galatasaray
Paylaşım için teşekkürler.
 
metal işleme
Üst