Hi, I have the four methods, they are pretty similar.
private void MovePieceToUpperStation(Button currentButton, string rowId, string colId)
{
if (rowId == "8")
return;
var nextButtonName = ButtonNameNextToCurrentOneGetter.GetButtonNameOfTheUpperStation(colId, rowId);
MovePieceToNextStation(currentButton, nextButtonName);
}
private void MovePieceToLowerStation(Button currentButton, string rowId, string colId)
{
if (rowId == "1")
return;
var nextButtonName = ButtonNameNextToCurrentOneGetter.GetButtonNameOfTheLowerStation(colId, rowId);
MovePieceToNextStation(currentButton, nextButtonName);
}
private void MovePieceToRightStation(Button currentButton, string rowId, string colId)
{
if (colId == "H")
return;
var nextButtonName = ButtonNameNextToCurrentOneGetter.GetButtonNameOfTheRightStation(rowId, colId);
MovePieceToNextStation(currentButton, nextButtonName);
}
private void MovePieceToLeftStation(Button currentButton, string rowId, string colId)
{
if (colId == "A")
return;
var nextButtonName = ButtonNameNextToCurrentOneGetter.GetButtonNameOfTheLeftStation(rowId, colId);
MovePieceToNextStation(currentButton, nextButtonName);
}
My question is I do not want repeat them. Is there a good way to do that?
For example, using generic.
What I have tried:
May pass another parameter to the method?