Advertisement
avr39ripe

BV012enumBasics

Mar 2nd, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     enum Directions {front=1,back,left,right};
  6.  
  7.     //enum Hands {left,right};
  8.  
  9.     //const int front{ 1 };
  10.     //const int back{ 2 };
  11.     //const int left{ 3 };
  12.     //const int right{ 4 };
  13.  
  14.     Directions monsterDirection{ front };
  15.  
  16.     //...
  17.     monsterDirection = -158;
  18.  
  19.     if (monsterDirection == front)
  20.     {
  21.         //.. some front action
  22.     }
  23.     else if (monsterDirection == back)
  24.     {
  25.         //.. some back action
  26.     }
  27.     else if (monsterDirection == left)
  28.     {
  29.         //.. some left action
  30.     }
  31.     else if (monsterDirection == right)
  32.     {
  33.         //.. some right action
  34.     }
  35.     else
  36.     {
  37.         //.. invalid direction
  38.     }
  39. }
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement