PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#requires Python version >=3.10 with match-case and currently does not work in Sololearn.
from enum import StrEnum
#locations (can be modified)
loc = StrEnum('loc', ['Home','Office','MeetingRoom','Gym'])
#actions (can be modified)
act = StrEnum('act',['Music','Meeting','Workout'])
class Employee:
def __init__(self, cloc=loc.Home):
self.cloc = cloc
print(f'Employee initialized at {self.cloc}')
#execute actions
def doit(self, act):
#valid action for self.cloc (can be modified)
match [self.cloc, act]:
case [loc.Home, act.Music]:
print('At home listening to music')
case [loc.Office, act.Meeting]:
print('At office attending meeting')
case [loc.Gym, act.Music]:
print('At gym listening to music')
case [loc.Gym, act.Workout]:
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run