i have a winform, and i added class, but when i added it, i got mistakes on the static classes i have inside. basically, it converts the code automatically to a form once it is located inside WinFormApplication1 and i dont know how to interact between the code and what i have in my original form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class ChessCode : Form
{
public static bool MATE;
Pieces[,] pieces;
public void ExecuteAll(int rowStart, int columnStart,int rowEnd,int columnEnd)
{
pieces = ChessBoard();
//Castling
CastlingMeh castle = new CastlingMeh();
castle.CastlingCheck(pieces, rowStart, columnStart, rowEnd, columnEnd);
//Promotion
Promotion(pieces, rowStart, columnStart, rowEnd, columnEnd);
//CheckManager
CheckManager.CheckOrMate(pieces, rowStart, columnStart, rowEnd, columnEnd);
if (MATE)
{
}
printChessBoard(pieces);
}
public static void printChessBoard(Pieces[,] pieces)
{
for (int i = 1; i < 9; i++)
{
Console.Write(" " + i + " ");
}
Console.WriteLine();
for (int i = 1; i < 9; i++)
{
Console.Write(i + " ");
for (int j = 1; j < 9; j++)
{
if (pieces[i, j] != null)
{
pieces[i, j].print();
}
else
{
Console.Write("! N !");
}
}
Console.WriteLine();
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
}
/// <summary>
/// //////////////////////////////////////////////////////////////////////////////////////////////////////
/// </summary>
/// <summary>
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// </summary>
/// <returns></returns>
public static Pieces[,] ChessBoard()
{
Pieces[,] piece = new Pieces[9, 9];
piece[8, 1] = new Rook("WR");
piece[8, 2] = new Knight("WKN");
piece[8, 3] = new Bishop("WB");
piece[8, 5] = new Queen("WQ");
piece[8, 4] = new King("WK");
piece[8, 6] = new Bishop("WB");
piece[8, 7] = new Knight("WKN");
piece[8, 8] = new Rook("WR");
piece[7, 1] = new Pawn("WP");
piece[7, 2] = new Pawn("WP");
piece[7, 3] = new Pawn("WP");
piece[7, 4] = new Pawn("WP");
piece[7, 5] = new Pawn("WP");
piece[7, 6] = new Pawn("WP");
piece[7, 7] = new Pawn("WP");
piece[7, 8] = new Pawn("WP");
piece[1, 1] = new Rook("BR");
piece[1, 2] = new Knight("BKN");
piece[1, 3] = new Bishop("BB");
piece[1, 5] = new Queen("BQ");
piece[1, 4] = new King("BK");
piece[1, 6] = new Bishop("BB");
piece[1, 7] = new Knight("BKN");
piece[1, 8] = new Rook("BR");
piece[2, 1] = new Pawn("BP");
piece[2, 2] = new Pawn("BP");
piece[2, 3] = new Pawn("BP");
piece[2, 4] = new Pawn("BP");
piece[2, 5] = new Pawn("BP");
piece[2, 6] = new Pawn("BP");
piece[2, 7] = new Pawn("BP");
piece[2, 8] = new Pawn("BP");
return piece;
}
public static Pieces[,] Promotion(Pieces[,] pieces, int rowStart, int columnStart, int rowEnd, int columnEnd)
{
PiecePromotion promotion = new PiecePromotion();
Object[,] choice2 = new Object[1, 5];
Object[,] choice = new Object[1, 5];
bool whitePromo = false;
bool blackPromo = false;
if (pieces[rowEnd, columnEnd] != null && pieces[rowEnd, columnEnd].pieceName()[1] == 'P' && (rowEnd == 1 || rowEnd == 8))
{
if (pieces[rowEnd, columnEnd].pieceName()[0] == 'B')
{
blackPromo = true;
}
else
{
whitePromo = true;
}
promotion.promotionPresentation(choice, choice2, blackPromo, whitePromo);
if (whitePromo)
{
pieces = promotion.promoteWhite(pieces, rowStart, columnStart, columnEnd, rowEnd, choice2);
}
else
{
pieces = promotion.promoteBlack(pieces, rowStart, columnStart, columnEnd, rowEnd, choice);
}
}
return pieces;
}
//private void InitializeComponent()
//{
// this.SuspendLayout();
// //
// // Chess
// //
// this.ClientSize = new System.Drawing.Size(292, 266);
// this.Name = "Chess";
// this.Load += new System.EventHandler(this.Chess_Load);
// this.ResumeLayout(false);
//}
i get the following mistakes:
Error 2 Inconsistent accessibility: parameter type 'Pieces[*,*]' is less accessible than method 'WindowsFormsApplication1.ChessCode.printChessBoard(Pieces[*,*])' D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\ChessBoardGame\ChessBoardGame\ChessCode.cs 39 28 ChessBoardGame
Error 3 Inconsistent accessibility: return type 'Pieces[*,*]' is less accessible than method 'WindowsFormsApplication1.ChessCode.ChessBoard()' D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\ChessBoardGame\ChessBoardGame\ChessCode.cs 81 34 ChessBoardGame
Error 4 Inconsistent accessibility: parameter type 'Pieces[*,*]' is less accessible than method 'WindowsFormsApplication1.ChessCode.Promotion(Pieces[*,*], int, int, int, int)' D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\ChessBoardGame\ChessBoardGame\ChessCode.cs 129 33 ChessBoardGame
Error 5 Inconsistent accessibility: return type 'Pieces[*,*]' is less accessible than method 'WindowsFormsApplication1.ChessCode.Promotion(Pieces[*,*], int, int, int, int)' D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\ChessBoardGame\ChessBoardGame\ChessCode.cs 129 33 ChessBoardGame