Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement