class - Python attribute of combination of two objects -
I'm quite new in OOP in Python In a program, I have two types of classes:
class character: ... etc ... [
character1 and
Character2 are examples of this) / P>
and
class room: ... etc ... <
[
Room1 and < code> Room2 are examples of this]
I have a variable
pos for each
character and
cell
pos for each possible combination of two classes Balance is: Example for
:
Type 1 with cell 1 - & gt; Pos = (10, 4) Room 1 - & gt; Pos = (6, 10) Room 2 with cell 2 - & gt; Pos = (3, 12) with class 2, character 2 - & gt; Pos = (7, 5)
Is there an easy way to create an attribute for the combination of the classes I described? I have looked around the internet and I have not found any way to do this.
Thanks in advance.
You can make a tuple of your character and room examples, then add that topless to anything Use as a key to store the value of.
([character 1, cell1]] = (10, 4) You have to allow each of the characters to be repeated And you can also create a collection of rooms.
Comments
Post a Comment