Programlama | Programlama Dilleri | C Programlama Dili |C++

Hata
  • XML Parsing Error at 1:82. Error 9: Invalid character


Satranç At Hareketi

AÇIKLAMA

C# dilinde yaz?lan bu programda amaç koordinatlar? verilen bir at?n oynayabilece?i yerlerin bulunmas?d?r.

 

 

Program?n Tamam?n? A?a??daki Linkten ?ndirebilirsiniz

Linki Görebilmeniz ?çin Üye Olman?z Gerekmektedir...

Üye Kay?t 

Program Kodu:

  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.ComponentModel;
  6.  
  7. using System.Data;
  8.  
  9. using System.Drawing;
  10.  
  11. using System.Linq;
  12.  
  13. using System.Text;
  14.  
  15. using System.Windows.Forms;
  16.  
  17.  
  18.  
  19. namespace Santranc
  20.  
  21. {
  22.  
  23.     public partial class Form1 : Form
  24.  
  25.     {
  26.  
  27.         Chess a = new Chess();
  28.  
  29.         public Form1()
  30.  
  31.         {
  32.  
  33.             InitializeComponent();
  34.  
  35.         }
  36.  
  37.  
  38.  
  39.         private void Form1_Load(object sender, EventArgs e)
  40.  
  41.         {
  42.  
  43.             a.Parent = this;
  44.  
  45.             a.Bounds = new Rectangle(20,20,600,600);
  46.  
  47.         }
  48.  
  49.     }
  50.  
  51. }
  52.  
  53. using System;
  54.  
  55. using System.Collections.Generic;
  56.  
  57. using System.Linq;
  58.  
  59. using System.Text;
  60.  
  61. using System.Windows.Forms;
  62.  
  63. using System.Drawing;
  64.  
  65.  
  66. namespace Santranc
  67.  
  68. {
  69.  
  70.     public class Chess : FlowLayoutPanel
  71.  
  72.     {
  73.  
  74.         private System.Windows.Forms.Button button;
  75.  
  76.         Image horse = Image.FromFile("At.jpg");
  77.  
  78.         Button[] butonlar = new Button[81];
  79.  
  80.         private int horseIndex = 0;
  81.  
  82.         public Chess()
  83.  
  84.         {
  85.  
  86.             this.BackColor = Color.RoyalBlue;
  87.  
  88.             int solduzlem = 8;
  89.  
  90.             int altduzlem = 1;
  91.  
  92.             for (int i = 0; i < 81; i++ )
  93.  
  94.             {
  95.  
  96.                 button = new Button();
  97.  
  98.                 button.Bounds = new System.Drawing.Rectangle(60*i,10,60,60);
  99.  
  100.  
  101.                 if (i % 9 == 0 || i > 71)
  102.  
  103.                 {
  104.  
  105.                     button.BackColor = Color.Tomato;
  106.  
  107.                     if (i < 71)
  108.  
  109.                     {
  110.  
  111.                         button.Text = solduzlem.ToString();
  112.  
  113.                         solduzlem--;
  114.  
  115.                     }
  116.  
  117.                     else if (i > 72)
  118.  
  119.                     {
  120.  
  121.                         button.Text =Convert.ToChar(altduzlem + 64).ToString();
  122.  
  123.                         altduzlem++;
  124.  
  125.                     }
  126.  
  127.                 }
  128.  
  129.                 else if (i % 2 == 0)
  130.  
  131.                 {
  132.  
  133.                     button.BackColor = Color.Black;
  134.  
  135.  
  136.                 }
  137.  
  138.                 else
  139.  
  140.                 {
  141.  
  142.                     button.BackColor = Color.White;
  143.  
  144.  
  145.                 }
  146.  
  147.  
  148.                 if (i == 65)
  149.  
  150.                 {
  151.  
  152.                     button.BackgroundImage = horse;
  153.  
  154.                     horseIndex = i;
  155.  
  156.  
  157.                 }
  158.  
  159.  
  160.                 this.Controls.Add(button);
  161.  
  162.                
  163.  
  164.                 button.Click += new System.EventHandler(this.button_Click);
  165.  
  166.                 button.Tag = i;
  167.  
  168.                 butonlar[i] = button;
  169.  
  170.             }
  171.  
  172.         }
  173.  
  174.         public void button_Click(object sender, EventArgs e)
  175.  
  176.         {
  177.  
  178.  
  179.             Button tik = (Button)sender;
  180.  
  181.             int a = Convert.ToInt32(tik.Tag);
  182.  
  183.  
  184.             if (a % 9 != 0 && a < 72)
  185.  
  186.             {
  187.  
  188.                 if (a - horseIndex == -7 || a - horseIndex == 7 || a - horseIndex == -11 || a - horseIndex == 11 || a - horseIndex == -17 || a - horseIndex == 17 || a - horseIndex == -19 || a - horseIndex == 19)
  189.  
  190.                 {
  191.  
  192.                     butonlar[horseIndex].BackgroundImage = null;
  193.  
  194.                     tik.BackgroundImage = horse;
  195.  
  196.                     horseIndex = a;
  197.  
  198.                 }
  199.  
  200.                 else
  201.  
  202.                 {
  203.  
  204.                     MessageBox.Show("Geçersiz Hamle");
  205.  
  206.                 }
  207.  
  208.             }
  209.  
  210.  
  211.         }
  212.  
  213.     }
  214. }

Yorumlar (0)
Sadece kayıtlı kullanıcılar yorum yazabilir!
Son Güncelleme ( Pazartesi, 30 Nisan 2012 09:34 )  
404 Not Found

404

Not Found

The resource requested could not be found on this server!


Proudly powered by LiteSpeed Web Server

Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.