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

16 lines
374 B
Python
Raw Normal View History

2024-04-16 11:47:52 +02:00
from enum import Enum
2024-06-03 13:20:55 +02:00
2024-04-16 11:47:52 +02:00
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]
2024-06-03 13:20:55 +02:00
return ShipDirection.UNKNOWN