How do I know when to make something a class instead of an instance of a class? For example:
If I'm creating a space game (I'm not), and I want the environment to be the Universe, I'd write:
class Universe:
def __init__(self):
pass
Now let's say I'd like to fill my Universe with Galaxies, so I'd make a Galaxy subclass, with size and name parameters:
class Galaxy(Universe):
def __init__(self, size, name):
super().__init__(self):
self.size = size
self.name = name
pass
Next, I'd like to make Planets. If this were the case, I should make a subclass of the Galaxy subclass right?
class Planet(Galaxy):
def __init__(self, type, climate):
super().__init__(self, size, name):
self.type = type
self.climate = climate
pass
From here I'd like to make the Planet types, or "families". What's the best way to go about this? Another subclass of a subclass? Each planet will contain resources that are unique to that family of planets. Should I then make this:
class PlanetType(Planet):
resources = []
def __init__(self, resources):
super().__init__(self, type, climate)
self.resources = resources
pass