Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ChessTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- Figure f = new Figure(1, 7);
- ChessTable.CheckPosition(f);
- for (int i = 0; i < f.wentsList.Count; i++)
- {
- Console.WriteLine((string)f.wentsList[i].ToString());
- }
- Console.ReadLine();
- }
- }
- public struct Wents
- {
- public string Name { get; set; }
- public bool isValid { get; set; }
- public int deltaX { get; set; }
- public int deltaY { get; set; }
- public Wents(string name, int y, int x) : this()
- {
- Name = name;
- deltaX = x;
- deltaY = y;
- }
- public override string ToString()
- {
- return String.Format("The went {0} is {1}",Name,isValid);
- }
- }
- public class Figure
- {
- public List<Wents> wentsList= new List<Wents>();
- public Tuple<int, int> tulpe;
- public Figure(int x, int y)
- {
- WentsInit();
- tulpe = new Tuple<int, int>(x, y);
- }
- private void WentsInit()
- {
- wentsList.Add(new Wents("Y+2;X+1", +2, +1));
- wentsList.Add(new Wents("Y+2;X-1", +2, -1));
- wentsList.Add(new Wents("Y-2;X+1", -2, +1));
- wentsList.Add(new Wents("Y-2;X-1", -2, -1));
- wentsList.Add(new Wents("Y+1;X+2", +1, +2));
- wentsList.Add(new Wents("Y-1;X+2", -1, +2));
- wentsList.Add(new Wents("Y+2;X+1", +1, -2));
- wentsList.Add(new Wents("Y-2;X-1", -1, -2));
- }
- }
- public static class ChessTable
- {
- private static int[,] _table = new int[7, 7];
- public static void CheckPosition(Figure f)
- {
- for (int i = 0; i < f.wentsList.Count; i++)
- {
- try
- {
- int _i = _table[f.tulpe.Item1 + f.wentsList[i].deltaX, f.tulpe.Item2 + f.wentsList[i].deltaY];
- Wents w = f.wentsList[i];
- w.isValid = true;
- f.wentsList[i] = w;
- }
- catch
- {
- System.Console.WriteLine("IOF");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment