hnc-daniil/HNC/Exercises/Ship_Battle/ShipDirection.py

15 lines
373 B
Python
Raw Normal View History

2024-04-16 11:47:52 +02:00
from enum import Enum
class ShipDirection(Enum):
2024-04-29 19:05:10 +02:00
VERTICAL = "VERTICAL"
HORIZONTAL = "HORIZONTAL"
2024-04-29 19:33:00 +02:00
UNKNOWN = "UNKNOWN"
@staticmethod
def from_string(raw_value):
if raw_value:
2024-05-06 18:47:26 +02:00
value = raw_value.upper()
2024-04-29 19:33:00 +02:00
if value in ShipDirection.__members__:
return ShipDirection[value]
return ShipDirection.UNKNOWN