File size: 1,465 Bytes
c7b88cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Location:
    """
    A class to represent a location in the simulated environment.

    Attributes:
    ----------
    name : str
        The name of the location.
    description : str
        A brief description of the location.

    Methods:
    -------
    describe():
        Prints the description of the location.
    """

    def __init__(self, name, description):
        self.name = name
        self.description = description
    
    def __str__(self):
        return self.name
    
    def describe(self):
        print(self.description)

class Locations:
    """
    A class to represent a collection of locations in the simulated environment.

    Attributes:
    ----------
    locations : dict
        A dictionary of locations, with keys as the location names and values as Location objects.

    Methods:
    -------
    add_location(name, description):
        Adds a new location to the collection.
    
    get_location(name):
        Returns the Location object with the given name.
    
    __str__():
        Returns a string representation of the collection of locations.
    """
    
    def __init__(self):
        self.locations = {}

    def add_location(self, name, description):
        self.locations[name] = Location(name, description)

    def get_location(self, name):
        return self.locations.get(name)

    def __str__(self):
        return '\n'.join([str(location) for location in self.locations.values()])