SHARE
TWEET

Untitled

a guest Oct 10th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MotorService
  2. {
  3.     public void RotateMotor(double speed, bool isClockwise)
  4.     {
  5.         //SOME ARG VALIDATION
  6.         if (speed <= 0)
  7.             throw new ArgumentOutOfRangeException("speed must be greater than zero");
  8.         //CONVERT SPEED TO WHATEVER SPECIAL UNITS
  9.         double convertedSpeed = speed * 1000 / 3;
  10.         //CONDITIONALLY ROTATE
  11.         if (isClockwise)
  12.         {
  13.             SendRotateClockwiseCommand(convertedSpeed);
  14.         }
  15.         else
  16.         {
  17.             SendRotateCounterClockwiseCommand(convertedSpeed);
  18.         }
  19.         //MORE LOGIC...
  20.     }
  21.  
  22.     protected void SendRotateClockwiseCommand(double speed)
  23.     {
  24.         Console.WriteLine("Rotating clockwise at speed: " + speed);
  25.     }
  26.  
  27.     protected void SendRotateCounterClockwiseCommand(double speed)
  28.     {
  29.         Console.WriteLine("Rotating counter clockwise at speed: " + speed);
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top