I m mit C# Switch Fall, wie ich mit Vererbung ersetzen kann. Fall ist wie 1,2,3,4 so wie kann ich es implementieren.
z.B.:
public Blocks(int code)
{
bool[,] shp1;
switch (code)
{
case 1:
this._Width = 4;
this._Height = 1;
this._Top = 0;
this._Left = 4;
shp1 = new bool[_Width, _Height];
shp1[0, 0] = true;
shp1[1, 0] = true;
shp1[2, 0] = true;
shp1[3, 0] = true;
this.Shape = shp1;
break;
case 2:
this._Width = 2;
this._Height = 2;
this._Top = 0;
this._Left = 4;
shp1 = new bool[_Width, _Height];
shp1[0, 0] = true;
shp1[0, 1] = true;
shp1[1, 0] = true;
shp1[1, 1] = true;
this.Shape = shp1;
break;
default:
throw new ArgumentException("Invalid Block Code");
}
}