public void Robot_At_0_0_E_Report_0_0_S_AfterRightCommand() { //arrange TRobot robot = new TRobot(); //act string result = robot.Commands("PLACE 0,0,EAST"); result = robot.Commands("RIGHT"); result = robot.Commands("REPORT"); //assert Assert.AreEqual("0,0,SOUTH", result); }
public void Robot_At_0_0_N_Report_0_0_W_AfterLeftCommand() { //arrange TRobot robot = new TRobot(); //act string result = robot.Commands("PLACE 0,0,NORTH"); result = robot.Commands("LEFT"); result = robot.Commands("REPORT"); //assert Assert.AreEqual("0,0,WEST", result); }
public void EdgeTestCase_Example_2() { //arrange TRobot robot = new TRobot(); //act string result = robot.Commands("PLACE 0,0,NORTH"); result = robot.Commands("LEFT"); result = robot.Commands("REPORT"); //assert Assert.AreEqual("0,0,WEST", result); }
public void Robot_At_0_0_N_Report_0_0_N_AfterSingleMove() { //arrange TRobot robot = new TRobot(); //act string result = robot.Commands("PLACE 0,0,NORTH"); result = robot.Commands("MOVE"); result = robot.Commands("REPORT"); //assert Assert.AreEqual("0,1,NORTH", result); }
public void StopAll() { for (int i = 0; i < Count; i++) { try { this[i].Brake(); } catch (Exception E) { TRobot.Writeln($"Motor is not working properly [index {i.ToString()}]: " + E.Message); } } }
public void SetSpeed(int Speed) { for (int i = 0; i < Count; i++) { try { //this[i].On((sbyte) Speed); this[i].SetSpeed((sbyte)Speed); } catch (Exception E) { TRobot.Writeln($"Motor is not working properly [index {i.ToString()}]: " + E.Message); } } }
public void EdgeTestCase_Example_3() { //arrange TRobot robot = new TRobot(); //act string result = robot.Commands("PLACE 1,2,EAST"); result = robot.Commands("MOVE"); result = robot.Commands("MOVE"); result = robot.Commands("LEFT"); result = robot.Commands("MOVE"); result = robot.Commands("REPORT"); //assert Assert.AreEqual("3,3,NORTH", result); }
public void Print() { int Rows = GetLength(0); int Cols = GetLength(1); TRobot.Writeln("{"); for (int i = 0; i < Rows; i++) { string Str = " "; for (int k = 0; k < Cols; k++) { Str += this[i, k].ToString() + ", "; } TRobot.Writeln(Str); } TRobot.Writeln("};"); }
public static void Print(ref TMatrixObject Matr) { int Rows = Matr.GetLength(0); int Cols = Matr.GetLength(1); TRobot.Writeln("{"); for (int i = 0; i < Rows; i++) { string str = " "; for (int k = 0; k < Cols; k++) { str += Matr[i, k].ToString() + ", "; } TRobot.Writeln(str); } TRobot.Writeln("};"); }
/// <summary> /// This is the Interface of the Toy Robot Simulator. /// This Makes use of the library to run the Program /// </summary> static void Main(string[] args) { const string instructions = @" ********************************** ********************************** ** TOY ROBOT SIMULATOR ** ** ** ** With 6 x 6 Square Table Top ** ** ** ********************************** ********************************** ** # 1. PLACE - PLACE will put the toy robot on the table in position X,Y and facing NORTH, SOUTH, EAST or WEST. ** ** # 2. RIGHT - to turn the robot 90 degrees Right without changing its current position ** ** # 3. LEFT - to turn the robot 90 degrees left without changing its current position ** ** # 4. MOVE to move the robot one step forward in it's direction ** ** # 5. REPORT to print the current position of the robot. ** ** # 6. EXIT to exit the application ** "; Console.WriteLine(instructions); TRobot robot = new TRobot(); while (true) { Console.WriteLine("Enter a Valid Command :>"); var command = Console.ReadLine(); if (command == null) { continue; } if (command.Equals("EXIT")) { break; } Console.WriteLine(robot.Commands(command)); Console.WriteLine(); } }
public void Writeln(string str) { TRobot.Writeln(str); }