你好。我有以下的类:
public class Ship
{
public enum ValidShips
{
Minesweeper,
Cruiser,
Destroyer,
Submarine,
AircraftCarrier
}
public enum ShipOrientation
{
North,
East,
South,
West
}
public enum ShipStatus
{
Floating,
Destroyed
}
public ValidShips shipType { get; set; }
public ShipUnit[] shipUnit { get; set; }
public ShipOrientation shipOrientation { get; set; }
public ShipStatus shipStatus { get; set; }
public Ship(ValidShips ShipType, int unitLength)
{
shipStatus = ShipStatus.Floating;
shipType = ShipType;
shipUnit = new ShipUnit[unitLength];
for (int i = 0; i < unitLength; i++)
{
shipUnit[i] = new ShipUnit();
}
}
}
我希望能像这样继承这个类:
public class ShipPlacementArray : Ship
{
}
这很有道理。
我想知道如何删除基类的某些功能?
例如:
public ShipUnit[] shipUnit { get; set; } // from base class
i would like it to be:
public ShipUnit[][] shipUnit { get; set; } // in the derived class
我的问题是如何实现隐藏基类shipUnit的代码?
否则,我将在派生类中有两个shipUnit实现。
感谢您的时间。
ShipPlacementArray仅处理一艘船。但该数组反映了可以放置船只的方向。