I am new to C#, and I want to make a Chess Game project in Visual Studio using said language. The main plan involves creating a virtual class named Piece that inherits the PictureBox class (I see the Piece class as simply an image with added functionalities) and it also has an abstract Move method that will be overridden in the inheriting classes (Pawn, Rook etc.). Each type of piece should set the image of the PictureBox based on what color that piece is, and I want this to happen during the call of the constructor for that class. How do I set the image of the PictureBox?
Most of the questions I've seen were similar but the PictureBox was not inherited, it was a nested class, or I would simply not understand a lot of the functions people were talking about which is why I asked a very specific question.
The constructor for my Pawn class currently looks like this:
public Pawn(Coordinate coordinate, int color): base(coordinate, color)
{
if(color==BLACK)
{
//Get the BlackPawn.png image and use it
}
if(color==WHITE)
{
//Get the WhitePawn.png image and use it
}
//Other stuff
}
Also, if I inherit the PictureBox class do I also need to call its constructor in the Piece class constructor and be mindful of its parameters, like I did with the Pawn constructor:
Pawn(Coordinate coordinate, int color): base(coordinate, color){/*...*/}