Open yoldakicocuk opened 7 months ago
import random import time
class Player: def init(self, name): self.name = name self.money = 1000 self.job = None self.location = "City Center"
def display_stats(self): print(f"Name: {self.name}") print(f"Money: ${self.money}") print(f"Location: {self.location}") if self.job: print(f"Job: {self.job}") else: print("Unemployed")
class CityLifeSimulator: def init(self): self.player = None
def start_game(self): print("Welcome to City Life Simulator!") player_name = input("Enter your name: ") self.player = Player(player_name) self.intro() def intro(self): print(f"Welcome to the city, {self.player.name}!") print("You have $1000 to start with.") self.main_menu() def main_menu(self): while True: print("\nMain Menu:") print("1. Work") print("2. Visit Locations") print("3. View Stats") print("4. Quit") choice = input("Enter your choice: ") if choice == "1": self.work() elif choice == "2": self.visit_locations() elif choice == "3": self.player.display_stats() elif choice == "4": print("Thanks for playing!") break else: print("Invalid choice! Please try again.") def work(self): print("You look for a job...") time.sleep(2) job_list = ["Taxi Driver", "Restaurant Server", "Retail Salesperson"] self.player.job = random.choice(job_list) print(f"You got a job as a {self.player.job}!") time.sleep(2) print("You start working...") time.sleep(3) earnings = random.randint(50, 200) self.player.money += earnings print(f"You earned ${earnings}!") time.sleep(2) def visit_locations(self): print("\nLocations:") print("1. City Center") print("2. Residential Area") print("3. Industrial Zone") choice = input("Enter your choice: ") if choice == "1": print("You visit the City Center.") self.player.location = "City Center" elif choice == "2": print("You visit the Residential Area.") self.player.location = "Residential Area" elif choice == "3": print("You visit the Industrial Zone.") self.player.location = "Industrial Zone" else: print("Invalid choice!")
game = CityLifeSimulator() game.start_game()
Very good
import random import time
class Player: def init(self, name): self.name = name self.money = 1000 self.job = None self.location = "City Center"
class CityLifeSimulator: def init(self): self.player = None
Instantiate and start the game
game = CityLifeSimulator() game.start_game()