Hi guys, thanks for all the help lately, but I require some more :o
I need it that the user is able to choose what is on the controller, when I type in a valid option I test for it that it gets to that point but it does not complete the action.
Here is the code:

import random
class TV(object):
    def __init__(self):
        tvslct=("40 inch LCD","70 inch 3D","15 inch old school")
        self.tv = random.choice(tvslct)
        self.state = 0
        self.channel = 1
        self.channelnames=["BBC 1","BBC 2","ITV 1","Channel 4","FIVE","ITV2","BBC 3","ITV3","BBC 4","Sky 3","Yesterday","Channel 4+1","More 4","Film 4"]
        print("You have been given a",self.tv,"Tv.")
        print("The Tv has been setup.")

    def turnon(self):
        if self.state==1:
            print("The Tv is already on.")
        else:
            self.state=1
            print("The Tv has turned on.")
    def turnoff(self):
        if self.state==0:
            print("The Tv is already off.")
        else:
            self.state=0
            print("The Tv has turned off.")

    def changechannels(self):
        if self.state==1:
            self.channel=999
            while not self.channel in range(0,15):
                try:
                    self.channel = int(input("Channel No."))
                except ValueError:
                    print("Enter a integer between 0 and",self.channels,".")
            print("The channel has been change to",self.channelnames[self.channel-1])
        else:
            print("The action could not be completed as the Tv is turned off.")

    def findchannels(self):
        if self.state==1:
            self.channels=0
            prevchannels=channels
            self.channels=random.randint(0,15)
            while self.channels < prevchannels:
                randint(0,15)
            print("The total Tv channels has been updated.")
            print("The Tv now has",self.channels,"channels.")
        else:
            print("The action could not be completed as the Tv is turned off.")
    def displaychannels(self):
        print("You have",self.channels,"channels.")
        print("Those channels are")
my_tv = TV()
QUIT=0
action=123
def wtd():
    print("""
                 ___________
                /___________\\
               |  [Turn on]  |
               |  [Turn off] |
               |  [Change    |
               |  channels]  |
               |   [Find     |
               |  channels]  |
               |  [Display   |
               |   channels] |
               |             |
               |_____________|
                \___________/
                 ____________
                |    Quit    |
                 ------------

                """)
    print("What would you like to do?")
while QUIT == 0:
    wtd()
    actions=("turnon","turnoff","changechannels","findchannels","displaychannels","quit")
    while not action in actions:
        try:
            action=input("Action: ").lower()
        except ValueError:
            print("A action name, stated on the controller, is required.")
    if action==("turnon"):
        print("cheese")
        my_tv.turnon
    elif action==("turnoff"):
        my_tv.turnoff
    elif action==("changechannels"):
        my_tv.changechannels
    elif action==("findchannels"):
        my_tv.findchannels
    elif action==("displaychannels"):
        my_tv.displaychannels
    elif action==("quit"):
        QUIT=1
    action=123

I will be very grateful for any help!!!!

Recommended Answers

All 6 Replies

bump because someone posted a pointless message on one of my earlier threads.

bump to reorder my threads again.

Please don't bump your threads. It's unfair to the owners of other threads.

Please don't bump your threads. It's unfair to the owners of other threads.

Im sorry for loss of views to any of your threads and in future cases I will not bump, but I need to reorder my threads as I need this one to be in front but some people are commenting more on my other thread which has been solved.

Thread closed due to owner of thread stupid mistake and has been solved.

Im sorry for loss of views to any of your threads and in future cases I will not bump, but

But, you're not really sorry and don't really care. Otherwise you'd refrain from bumping immediately rather than come up with a lame excuse to bump.

I need to reorder my threads as I need this one to be in front but some people are commenting more on my other thread which has been solved.

That's not how it works. People can reply to any thread they want; bumping the thread you want them to look at won't change this. All it does is push other threads down by one. This isn't too big of a problem except for the poor sap who's already at the bottom and gets pushed to page 2, which is the kiss of death for a thread because nobody looks there.

I'm sure you wouldn't want your thread to be ignored for the foreseeable future because someone else pushed you down with a pointless bump, so keep that in mind the next time you're tempted to bump one of your own threads.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.