-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest24.py
More file actions
44 lines (37 loc) · 885 Bytes
/
test24.py
File metadata and controls
44 lines (37 loc) · 885 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# coding: utf-8
from state import curr, switch, stateful, State, behavior
def workday():
print('work hard!')
def weekend():
print('play harder!')
#class People(object):
# pass
#people = People()
#while True:
while False:
for i in xrange(1, 8):
if i == 6:
people.day = weekend
if i == 1:
people.day = workday
people.day()
####################################
@stateful
class People(object):
class Workday(State):
default = True
@behavior
def day(self):
print('work hard.')
class Weekend(State):
@behavior
def day(self):
print('play harder!')
people = People()
while True:
for i in xrange(1, 8):
if i == 6:
switch(people, People.Weekend)
if i == 1:
switch(people, People.Workday)
people.day()