Python Forum
please help with classes and return values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
please help with classes and return values
#1
#!/usr/bin/python3

import module

class StartProgram():
    def display1(self):
        print("This is superclass")

    def function(self):
        print("Hello")

class CentralCorridor (): # main body
    def swim (self):
        print("""You have selected a very important part of the game""")

    def print_function(self):
        print("Welcome to my Classes Python Program!")
        print("What do you want to do?")
        print("1. Press (1) to win.")
        print("2. Press (2) to die.")

        action = input("> ")

        if action == "1":
            print("You won!")
            return 'finished'
        elif action == "2":
            print ("You died.")
            return 'death'
        elif action == "3":
            print ("You pressed '3'...")
            return 'death'
        else:
            print (f"The name of the string is {answer}".format (answer))

class Finished ():

    def __init__(self, first_name, last_name ="Fish"):
        self.first_name = first_name
        self.last_name = last_name

    def swim(self):
        print("The fish is swimming.")

    def swim_backwards (self):
        print("You won! Good job.")

class Death ():

    elements = []

    the_count = [5, 4, 3, 2, 1]

    for i in elements:
        print(f"And you die in...: {i}")

    def swim(self):
        print(Death.quips[randint(0, len(self.quips) -1)])

    quips = [   # dictionary
            "You died. You kinda suck at this.",
            "Your Mom would be proud...if she were smarter.",
            "Such a luser.",
            "I have a small puppy that's better at this.",
            "You're worse than your Dad's jokes."
    ]

print(module.tangerine)

g = CentralCorridor()
g.print_function()
Please, could someone please help me with the return value's, please, what would be the best way for these return statements

        if action == "1":
            print("You won!")
            return 'finished'
        elif action == "2":
            print ("You died.")
            return 'death'
        elif action == "3":
            print ("You pressed '3'...")
            return 'death'
to initialize the classes (Death() and Finished()). I will work on the inside of these afterward. Also, this is a question out of my book, "Learn Python 3 the hard way,", also, I plan on posting more to this thread and work more on it over the next few days, would like to add an "class Engine()" class which would include a while() loop with additional code that in the book is described as an Engine and called Engine(). Please, help with the return statements and post follow up code if I am not asking too much.
Reply


Messages In This Thread
please help with classes and return values - by jamie_01 - Jan-14-2022, 03:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to return 2 values from 1 DF that equals another DF cubangt 5 667 Oct-21-2023, 02:45 PM
Last Post: deanhystad
  [Solved]Return values from npyscreen Extra 2 1,197 Oct-09-2022, 07:19 PM
Last Post: Extra
  Parallelism with return values Plexian 7 1,539 Aug-14-2022, 09:33 AM
Last Post: Plexian
  Need to parse a list of boolean columns inside a list and return true values Python84 4 2,144 Jan-09-2022, 02:39 AM
Last Post: Python84
  Function - Return multiple values tester_V 10 4,537 Jun-02-2021, 05:34 AM
Last Post: tester_V
  Function to return list of all the INDEX values of a defined ndarray? pjfarley3 2 1,997 Jul-10-2020, 04:51 AM
Last Post: pjfarley3
  What is the best way to return these 4 integer values? Pedroski55 4 2,578 Apr-13-2020, 09:54 PM
Last Post: Pedroski55
  Return values for use outside of function willowman 1 1,700 Apr-13-2020, 07:00 AM
Last Post: buran
  Return all Values which can divided by 9 lastyle 2 1,861 Mar-16-2020, 09:22 PM
Last Post: lastyle
  Save all values to pandas of multiple classes jenniferruurs 0 1,919 Sep-13-2019, 12:10 PM
Last Post: jenniferruurs

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020