Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Mazes
  4. {
  5.     public static class EmptyMazeTask
  6.     {
  7.         public static bool MoveRight(Robot robot, int rightSide)
  8.         {
  9.             for (int i = robot.X; i < rightSide; i++)
  10.             {
  11.                 robot.MoveTo(Direction.Right);
  12.                 if (robot.Finished) return true;
  13.             }
  14.  
  15.             return false;
  16.         }
  17.  
  18.         public static bool MoveLeft(Robot robot, int leftSide)
  19.         {
  20.             for (int i = robot.X; i > leftSide; i--)
  21.             {
  22.                 robot.MoveTo(Direction.Left);
  23.                 if (robot.Finished) return true;
  24.             }
  25.  
  26.             return false;
  27.         }
  28.  
  29.         public static bool MoveDown(Robot robot, int DownSide)
  30.         {
  31.             for (int i = robot.Y; i < DownSide; i++)
  32.             {
  33.                 robot.MoveTo(Direction.Down);
  34.                 if (robot.Finished) return true;
  35.             }
  36.  
  37.             return false;
  38.         }
  39.  
  40.         public static bool MoveUp(Robot robot, int upSide)
  41.         {
  42.             for (int i = robot.Y; i > upSide; i--)
  43.             {
  44.                 robot.MoveTo(Direction.Up);
  45.                 if (robot.Finished) return true;
  46.             }
  47.  
  48.             return false;
  49.         }
  50.  
  51.         public static void MoveOut(Robot robot, int width, int height)
  52.         {
  53.             int rightSide = width - 2, downSide = height - 2;
  54.  
  55.             MoveRight(robot, rightSide);
  56.             MoveDown(robot, downSide);
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement