I am learning Python, following a book (Python Programming for the Absolute Beginner, 3rd Edition).
The book gives an example of a basic Sims like application, where a finite number of “critters” are created, and the user must feed and play with them, increasing their boredom and hunger values.
I was practicing using classes, and tried to make my own game. The user was presented with a menu where the user could; buy/create a new sim, delete an old one, or interact with existing ones.
The problem I’m having is with creating new classes. The user is initially presented with a screen asking what they would like to do, and if they press X, they are taken to the createnewsim function. However the problem is when a new class is made:
nameofsim = input("what would you like to call your new sim?")
newsim = sim(nameofsim)
If the user were to make another, it would overwrite the existing one, since the name newsim cannot be changed, as I discovered in a previous question, more or less.
So, how do I allocate new object names, or prevent old sims from being overwritten, allowing for the creations of more than one new sim??
Either store your sim classes in a list or a dictionary; e.g.