MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / Room

Class Room

29_pattern_matching_revisited/python/cmd_split.py:7–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5 sys.exit(0)
6
7class Room:
8 def __init__(self, objs=None):
9 self.objects = objs
10 if objs is None:
11 self.objects = set(["banana", "chair", "piano"])
12 def describe(self):
13 print("the room is dark and small, it contains", self.objects);
14 def neighbor(self, direction):
15 match direction:
16 case "left":
17 print("changed to room", direction)
18 return Room(set(["knife", "bread", "butter"]))
19 case "north":
20 print("changed to room", direction)
21 return Room(set(["polar-bear", "ice", "snow"]))
22 case "right" |"front" |"back":
23 print("No Room", direction)
24 case _:
25 print("unknown direction")
26 return self
27
28class Character:
29 def __init__(self):

Callers 2

neighborMethod · 0.70
cmd_split.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected