public static int Movement(int space)
Random random = new Random();
int temp = random.Next(1, 4);
int n = random.Next(1, 6);
public Robot(string newColor, int newNumOfSpaces, bool newIfInGame)
this.numOfSpaces = newNumOfSpaces;
this.ifInGame = newIfInGame;
public void SetColor(string newColor)
public int GetNumOfSpaces()
public void SetNumOfSpaces(int newNumOfSpaces)
this.numOfSpaces = newNumOfSpaces;
public bool GetifInGame()
public void SetifInGame(bool newIfInGame)
this.ifInGame = newIfInGame;
public void walkForward()
public void walkBackward()
public void jumpForward(int n)
this.numOfSpaces = this.numOfSpaces + n;
public void jumpBackward(int n)
this.numOfSpaces = this.numOfSpaces - n;
public static void Main()
Console.Write("Please enter a color for the first robot: ");
string robot1color = Console.ReadLine();
Robot robot1 = new Robot(robot1color, 10, true);
Console.Write("Please enter a color for the second robot: ");
string robot2color = Console.ReadLine();
Robot robot2 = new Robot(robot2color, 10, true);
int robot1Space = robot1.GetNumOfSpaces();
int robot2Space = robot2.GetNumOfSpaces();
string winner = "", winnerColor="",reasonForWin="";
if (robot1.GetifInGame() == false)
winnerColor = robot2color;
reasonForWin = winner+ " was the last Robot in the game and therefor the winning robot is: ";
if (robot2.GetifInGame() == false)
winnerColor = robot1color;
reasonForWin = winner + " was the last Robot in the game and therefor the winning robot is: ";
winnerColor = robot1color;
reasonForWin = "robot1 reached the desired area and the winner of the game is: ";
winnerColor = robot2color;
reasonForWin = "robot2 reached the desired area and the winner of the game is: ";
winnerColor = robot2color;
reasonForWin = "robot1 moved out of the allowed area and the wineer is: ";
winnerColor = robot1color;
reasonForWin = "robot2 moved out of the allowed area and the wineer is: ";
if (robot1Space > 0 && robot2Space > 0 && robot1Space < 100 && robot2Space < 100)
robot1Space = Movement(robot1Space);
Console.WriteLine("Robot1 has moved to {0}.", robot1Space);
if (robot1Space == robot2Space)
winnerColor = robot1color;
reasonForWin = winner + " moved to robot2 place and for that he won game. the winner is: ";
robot2Space = Movement(robot2Space);
Console.WriteLine("Robot2 has moved to {0}.", robot2Space);
if (robot2Space == robot1Space)
winnerColor = robot2color;
reasonForWin = winner + " moved to robot1 place and for that he won game. the winner is: ";
Console.WriteLine(reasonForWin+winner +" and the color of the robot is: " +winnerColor);