特定の値を含むオブジェクトを削除するメソッドを呼び出しています。次のようになります。
static public void RemovePiece(string BoardId)
{
LumberPiece board = LocateBoard(BoardId);
board = null;
}
LumberPiece は次のようなクラスです。
private class LumberPiece
{
public string boardID;
...
}
LocateBoard は、正しく識別された LumberPiece オブジェクトを返す関数です。
static private LumberPiece LocateBoard(string BoardId)
{
if (SawyerArea.lumber.boardID == BoardId)
return SawyerArea.lumber;
else if (SpliceArea1.lumber.boardID == BoardId)
return SpliceArea1.lumber;
else if (SpliceArea2.lumber.boardID == BoardId)
return SpliceArea2.lumber;
else
throw new Exception("Your LumberID was not found in any activity area. Has it already been removed? or are you handling the integer-String Conversion Correctly");
}
Area 変数は、このクラスのインスタンスです。
private class ActivityArea
{
public Sensor sensor;
public ClampSet clampSet;
public Servo servo;
public LumberPiece lumber;
public bool IsCurrentlyFilled()
{
if (lumber != null)
return true;
else
return false;
}
public ActivityArea(Sensor s, ClampSet cs, Servo srv)
{
sensor = s;
clampSet = cs;
servo = srv;
}
正しく識別された LumberPiece オブジェクトを削除するにはどうすればよいですか?