コード例 #1
0
 public static void testTranRobot(TranRobot obj)
 {
     Console.WriteLine("robot is intially at ");
     printTransRobotCoord(obj);
     obj.Forward();
     Console.Write("robot used forward()");
     printTransRobotCoord(obj);
     obj.Forward();
     Console.Write("robot used forward()");
     printTransRobotCoord(obj);
     obj.Left();
     Console.Write("robot used left()");
     printTransRobotCoord(obj);
     obj.Right();
     Console.Write("robot used Right()");
     printTransRobotCoord(obj);
     obj.Back();
     Console.Write("robot used Back()");
     printTransRobotCoord(obj);
 }
コード例 #2
0
    public static robot[] generateRobot()
    {
        int batterylife = 1;

        robot[] arr = new robot[SIZE];
        for (int i = 0; i < 3; i++)
        {
            arr[i] = new robot(directory, batterylife);
        }

        for (int i = 3; i < 6; i++)
        {
            arr[i] = new RotatingRobot(directory, batterylife);
        }

        for (int i = 6; i < 9; i++)
        {
            arr[i] = new TranRobot(directory, batterylife);
        }
        return(arr);
    }
コード例 #3
0
 public static void printTransRobotCoord(TranRobot obj)
 {
     Console.WriteLine("row:{0} Column:{1}", obj.getRow(), obj.getColumn());
 }