问候。我有以下课程:
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
我希望它是:
public ShipUnit[][] shipUnit { get; set; } // in the derived class
我的问题是如何实现完全隐藏基类 shipUnit 的代码?
否则我将在派生类中得到两个 shipUnit 实现。
感谢您的时间。
ShipPlacementArray 只处理一艘船。但阵列反映了船可以放置的方向。