Project 7
project7.py
print("Welcome to Project 7")
sam = character.Character("Sam")
print(sam)
character.py
class Character:
def __init__(self, name):
self.name = name
self.inventory = []
def add_item(self, item):
self.inventory.append(item)
def __str__(self):
return "Name: " + self.name
location.py
class Location:
def __init__(self, name, description):
self.name = name # e.g., "Enchanted Forest", "City Park"
self.description = description # Text describing the location
self.items = [] # Items available at this location
def add_item(self, item):
self.items.append(item)
def __str__(self):
return "Location: " + self.name
Last updated