Mar-31-2024, 08:44 PM
(This post was last modified: Mar-31-2024, 08:44 PM by menator01.
Edit Reason: Added more random
)
Here is one possible way.
from random import choice, randint class Character: def __init__(self, clothing, gear): self.name = choice(('Charlie', 'Troy', 'Elaina', 'Brenda', 'Ralph')) self.age = randint(18, 35) self.clothing = clothing self.gear = gear def __str__(self): return f' Name: {self.name}\n Age: {self.age}\n Clothing: {self.clothing}\n Gear: {self.gear}' class Clothing: def __init__(self): self.material = ('cotton', 'silk', 'leather') self.color = ('red', 'blue', 'green', 'black', 'white', 'yellow') self.top = f'{choice(self.color)} colored top made from {choice(self.material)}' self.pants = f'{choice(self.color)} colored pants made from {choice(self.material)}' self.belt = f'{choice(("rope", "leather", "cloth"))} belt' def __str__(self): return f'{self.top}, {self.pants}, {self.belt}' class Gear: def __init__(self): self.material = ('copper', 'bronze', 'iron', 'steel') self.color = ('gold', 'silver', 'bronze') self.sword = f'{choice(self.color)} colored sword made from {choice(self.material)}' self.shield = f'{choice(self.color)} colored shield made from {choice(self.material)} with a {choice(('dragon', 'eagle', 'snake'))} emblem on it' def __str__(self): return f'{self.sword} and {self.shield}' print(Character(Clothing(), Gear()))Output
Output: Name: Ralph
Age: 33
Clothing: blue colored top made from cotton, white colored pants made from leather, cloth belt
Gear: silver colored sword made from iron and bronze colored shield made from copper with a snake emblem on it
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags