| メソッド | 説明 |
|---|---|
| void setMsgArray (String[] msgArray) | メッセージの文字列配列を setします。 |
| String getPos() | 現在位置を表す文字列を返します。 |
| boolean toForward() | posX、posY を変更します。 direction の方向に移動します。 |
| void toRight() | direction を変更します。 |
| void lookBack() | direction を変更します。 |
| void toLeft() | direction を変更します。 |
| Cell rotatePosCell (int x0, int y0) | 相対位置で指定されたマスを、 directionに回転した値で返します。 |
| String message() | 現在位置のマスに従った文字列を返します。 |
| boolean action() | 現在位置のマスに従って、 階段の昇り降りイベントを実行します。 |
| boolean isOut() | floor の値が0以下になると true を返します。 |
private final static int NORTH = 0; private final static int EAST = 1; private final static int SOUTH = 2; private final static int WEST = 3; public String getPos(){ return String.format("%sF (%2s, %2s) %s", Integer.toString(floor+1, 10), Integer.toString(posX + displayX, 10), Integer.toString(posY + displayY, 10), strDirection() ); } private String strDirection(){ switch(direction){ case NORTH: return "NORTH"; case EAST: return "EAST"; case SOUTH: return "SOUTH"; case WEST: return "WEST"; default: return "Invalid direction."; } }
public void lookBack(){ direction += 2; direction %= 4; } public void toRight(){ direction++; direction %= 4; } public void toLeft(){ direction--; direction += 4; direction %= 4; }
public boolean isOut() { return floor < 0; }