## Creature Project ## CSC323 ## 4/17/10 ## Direction.py: Contains the Direction enumerated type: N,NE,E,SE,S,SW,W,NW,C. class Direction: @staticmethod def fromString(string): if string=="N": return N elif string=="NE": return NE elif string=="E": return E elif string=="SE": return SE elif string=="S": return S elif string=="SW": return SW elif string=="W": return W elif string=="NW": return NW else: #Not a Direction raise Error("Not a Direction") class N: x = 0 y = -1 def __str__(): return "N" class NE: x = 1 y = -1 def __str__(): return "NE" class E: x = 1 y = 0 def __str__(): return "E" class SE: x = 1 y = 1 def __str__(): return "SE" class S: x = 0 y = 1 def __str__(): return "S" class SW: x = -1 y = 1 def __str__(): return "SW" class W: x = -1 y = 0 def __str__(): return "W" class NW: x = -1 y = -1 def __str__(): return "NW" class C: x = 0 y = 0 def __str__(): return "C"