Direction.h

Go to the documentation of this file.
00001 
00014 #ifndef __DIRECTION__H__
00015 #define __DIRECTION__H__
00016 
00017 #include "common.h"
00018 #include "Conversions.h"
00019 
00023 class Direction {
00024 public:
00028         enum Directions {
00029                 UP = 1,
00030                 DOWN,
00031                 LEFT,
00032                 RIGHT
00033         };
00034 
00039          Direction(Directions direction = UP):
00040                 currentDirection(direction) {}
00041 
00046          explicit Direction(int direction) {
00047                 if (direction < UP || direction > RIGHT) {
00048                         THROW(ExceptionBadDirection, string("Direction number ") +
00049                                 Conversions::ToString(direction) + " is illegal.");
00050                 }
00051 
00052                 currentDirection = static_cast<Directions>(direction);
00053          }
00054 
00058          ~Direction() {}
00059 
00063         Directions GetDirection() const {
00064                 return currentDirection;
00065         }
00066 
00071         void SetDirection(Directions newDirection) {
00072                 currentDirection = newDirection;
00073         }
00074 
00075 private:
00077         Directions currentDirection;
00078 };
00079 
00080 #endif /* #ifndef __DIRECTION__H__ */
00081 
00082 /* End of file Direction.h */

Generated on Sun Apr 29 11:46:10 2007 for IPP/ICP2007 by  doxygen 1.4.7